ZQuest Classic Coverage Report


Directory: src/
File: src/zq/zquest.cpp
Date: 2025-06-30 08:47:23
Exec Total Coverage
Lines: 2261 14834 15.2%
Functions: 49 740 6.6%
Branches: 1400 11049 12.7%

Line Branch Exec Source
1 #include "allegro/gui.h"
2 #include "base/files.h"
3 #include "base/mapscr.h"
4 #include "dialog/edit_region.h"
5
6 #include <memory>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <cstring>
10 #include <sstream>
11 #include <ctype.h>
12 #include <assert.h>
13 #include <time.h>
14 #include <vector>
15 #include <filesystem>
16 #include <base/new_menu.h>
17
18 #include "dialog/info_lister.h"
19 #ifdef __APPLE__
20 // malloc.h is deprecated, but malloc also lives in stdlib
21 #include <stdlib.h>
22 #else
23 #include <malloc.h>
24 #endif
25
26 #include "zalleg/zalleg.h"
27 #include "base/qrs.h"
28 #include "base/dmap.h"
29 #include "base/msgstr.h"
30 #include "base/packfile.h"
31 #include "base/cpool.h"
32 #include "base/autocombo.h"
33 #include "base/render.h"
34 #include "base/version.h"
35 #include "zq/autocombo/autopattern_base.h"
36 #include "zq/autocombo/pattern_basic.h"
37 #include "zq/autocombo/pattern_flatmtn.h"
38 #include "zq/autocombo/pattern_fence.h"
39 #include "zq/autocombo/pattern_cakemtn.h"
40 #include "zq/autocombo/pattern_relational.h"
41 #include "zq/autocombo/pattern_dungeoncarve.h"
42 #include "zq/autocombo/pattern_dormtn.h"
43 #include "zq/autocombo/pattern_tiling.h"
44 #include "zq/autocombo/pattern_replace.h"
45 #include "zq/autocombo/pattern_denseforest.h"
46 #include "zq/autocombo/pattern_extend.h"
47 #include "zq/render_hotkeys.h"
48 #include "zq/render_minimap.h"
49 #include "zq/render_tooltip.h"
50 #include "base/misctypes.h"
51 #include "parser/Compiler.h"
52 #include "base/zc_alleg.h"
53 #include "particles.h"
54 #include "dialog/combopool.h"
55 #include "dialog/alert.h"
56 #include "dialog/alertfunc.h"
57 #include "zq/gui/edit_autocombo.h"
58
59 #include <al5_img.h>
60 #include <loadpng.h>
61 #include <fmt/format.h>
62
63 #include "dialog/cheat_codes.h"
64 #include "dialog/set_password.h"
65 #include "dialog/foodlg.h"
66 #include "dialog/quest_rules.h"
67 #include "dialog/script_rules.h"
68 #include "dialog/headerdlg.h"
69 #include "dialog/ffc_editor.h"
70 #include "dialog/screen_data.h"
71 #include "dialog/edit_dmap.h"
72 #include "dialog/compilezscript.h"
73 #include "dialog/screen_enemies.h"
74 #include "dialog/enemypattern.h"
75 #include "dialog/sfxdata.h"
76 #include "dialog/mapstyles.h"
77 #include "dialog/externs.h"
78
79 #include "base/gui.h"
80 #include "gui/jwin_a5.h"
81 #include "gui/jwin.h"
82 #include "zc_list_data.h"
83 #include "gui/editbox.h"
84 #include "zq/zq_misc.h"
85 #include "zq/zq_tiles.h" // tile and combo code
86
87 #include "zq/zquest.h"
88 #include "zq/ffasm.h"
89 #include "zq/render.h"
90
91 // the following are used by both zelda.cc and zquest.cc
92 #include "base/zdefs.h"
93 #include "base/qrs.h"
94 #include "tiles.h"
95 #include "base/colors.h"
96 #include "base/qst.h"
97 #include "base/zsys.h"
98 #include "base/zapp.h"
99 #include "base/process_management.h"
100 #include "play_midi.h"
101 #include "sound/zcmusic.h"
102
103 #include "midi.h"
104 #include "sprite.h"
105 #include "fontsdat.h"
106 #include "base/jwinfsel.h"
107 #include "zq/zq_class.h"
108 #include "subscr.h"
109 #include "zq/zq_subscr.h"
110 #include "zc/ffscript.h"
111 #include "gui/EditboxNew.h"
112 #include "sfx.h"
113 #include "zq/zq_custom.h" // custom items and guys
114 #include "zq/zq_strings.h"
115 #include "zq/questReport.h"
116 #include <fstream>
117 #include "drawing.h"
118 #include "zconsole/ConsoleLogger.h"
119 #include "colorname.h"
120 #include "zq/zq_hotkey.h"
121 #include "zq/package.h"
122 #include "zq/zq_files.h"
123 #include "music_playback.h"
124
125 //Windows mmemory tools
126 #ifdef _WIN32
127 #include <windows.h>
128 #include <stdio.h>
129 #include <psapi.h>
130 #pragma comment(lib, "psapi.lib") // Needed to avoid linker issues. -Z
131 #endif
132
133 #ifdef __EMSCRIPTEN__
134 #include <emscripten/emscripten.h>
135 #endif
136
137 #define MIDI_TRACK_BUFFER_SIZE 50
138 extern CConsoleLoggerEx parser_console;
139
140 using ZScript::disassembled_script_data;
141 void write_script(vector<shared_ptr<ZScript::Opcode>> const& zasm, string& dest,
142 bool commented, map<string,disassembled_script_data>* scr_meta_map);
143
144 namespace fs = std::filesystem;
145
146 #if defined(ALLEGRO_WINDOWS)
147 static const char *data_path_name = "win_data_path";
148 static const char *midi_path_name = "win_midi_path";
149 static const char *image_path_name = "win_image_path";
150 static const char *tmusic_path_name = "win_tmusic_path";
151 static const char *last_quest_name = "win_last_quest";
152 static const char *qtname_name = "win_qtname%d";
153 static const char *qtpath_name = "win_qtpath%d";
154 #elif defined(ALLEGRO_LINUX)
155 static const char *data_path_name = "linux_data_path";
156 static const char *midi_path_name = "linux_midi_path";
157 static const char *image_path_name = "linux_image_path";
158 static const char *tmusic_path_name = "linux_tmusic_path";
159 static const char *last_quest_name = "linux_last_quest";
160 static const char *qtname_name = "linux_qtname%d";
161 static const char *qtpath_name = "linux_qtpath%d";
162 #elif defined(__APPLE__)
163 static const char *data_path_name = "macosx_data_path";
164 static const char *midi_path_name = "macosx_midi_path";
165 static const char *image_path_name = "macosx_image_path";
166 static const char *tmusic_path_name = "macosx_tmusic_path";
167 static const char *last_quest_name = "macosx_last_quest";
168 static const char *qtname_name = "macosx_qtname%d";
169 static const char *qtpath_name = "macosx_qtpath%d";
170 #endif
171
172 #include "base/win32.h"
173
174 #include "zq/zq_init.h"
175 #include "zq/zq_doors.h"
176 #include "zq/zq_cset.h"
177 #include "zinfo.h"
178
179 #ifdef _MSC_VER
180 #include <crtdbg.h>
181
182 #endif
183
184 // MSVC fix
185 #if _MSC_VER >= 1900
186 FILE _iob[] = { *stdin, *stdout, *stderr };
187 extern "C" FILE * __cdecl __iob_func(void) { return _iob; }
188 #endif
189
190 extern byte monochrome_console;
191
192 #include "zconsole/ConsoleLogger.h"
193
194 extern CConsoleLoggerEx zscript_coloured_console;
195
196 uint8_t console_is_open = 0;
197 bool is_zq_replay_test = false;
198
199 #include "base/util.h"
200
201 #ifdef __EMSCRIPTEN__
202 #include "base/emscripten_utils.h"
203 #endif
204
205 using namespace util;
206
207 using std::vector;
208 using std::map;
209 using std::stringstream;
210
211 12 FFScript FFCore;
212
213 void load_size_poses();
214 void do_previewtext();
215 bool do_slots(vector<shared_ptr<ZScript::Opcode>> const& zasm,
216 map<string, disassembled_script_data> &scripts, int assign_mode);
217
218 int32_t startdmapxy[6] = {-1000, -1000, -1000, -1000, -1000, -1000};
219 bool cancelgetnum=false;
220
221 int32_t tooltip_timer=0, tooltip_maxtimer=30, tooltip_current_ffc=0;
222 int32_t combobrushoverride=-1;
223 ComboPosition mouse_combo_pos;
224
225 int32_t original_playing_field_offset=0;
226 12 int32_t playing_field_offset=original_playing_field_offset;
227 int32_t passive_subscreen_height=56;
228
229 bool disable_saving=false, OverwriteProtection;
230 bool halt=false;
231 bool show_sprites=true;
232 bool show_hitboxes = false;
233 bool zq_ignore_item_ownership = true;
234
235 // Used to find FFC script names
236 vector<string> asffcscripts;
237 vector<string> asglobalscripts;
238 vector<string> asitemscripts;
239 vector<string> asnpcscripts;
240 vector<string> aseweaponscripts;
241 vector<string> aslweaponscripts;
242 vector<string> asplayerscripts;
243 vector<string> asdmapscripts;
244 vector<string> asscreenscripts;
245 vector<string> asitemspritescripts;
246 vector<string> ascomboscripts;
247 vector<string> asgenericscripts;
248 vector<string> assubscreenscripts;
249
250 vector<string> ZQincludePaths;
251
252 int32_t CSET_SIZE = 16;
253 int32_t CSET_SHFT = 4;
254 //editbox_data temp_eb_data;
255 /*
256 #define CSET(x) ((x)<<CSET_SHFT)
257 #define csBOSS 14
258 */
259
260 /*
261 enum { m_block, m_coords, m_flags, m_guy, m_warp, m_misc, m_layers,
262 m_menucount };
263 */
264 void update_combo_cycling();
265 void update_freeform_combos();
266
267 /*
268 #define MAXMICE 14
269 #define MAXARROWS 8
270 #define SHADOW_DEPTH 2
271 */
272 int32_t coord_timer=0, coord_frame=0;
273 int32_t blackout_color, zq_screen_w, zq_screen_h;
274 int32_t draw_mode=0;
275
276 12 size_and_pos minimap;
277 12 size_and_pos real_minimap;
278
279 12 size_and_pos minimap_zoomed;
280 12 size_and_pos real_minimap_zoomed;
281
282 12 size_and_pos map_page_bar[9];
283 int32_t mappage_count = 9;
284
285 12 size_and_pos combolist[MAX_COMBO_COLS];
286 12 size_and_pos combolistscrollers[MAX_COMBO_COLS];
287 int32_t num_combo_cols = MAX_COMBO_COLS;
288
289 static bool zoom_in_btn_disabled;
290 static bool zoom_out_btn_disabled;
291 12 size_and_pos zoominbtn;
292 12 size_and_pos zoomoutbtn;
293 12 size_and_pos compactbtn;
294 12 size_and_pos mainbar;
295
296 12 size_and_pos screrrorpos;
297
298 12 size_and_pos comboaliaslist[MAX_COMBO_COLS];
299 12 size_and_pos comboalias_preview;
300 12 size_and_pos combopool_preview;
301 12 size_and_pos combopool_prevbtn;
302
303 12 size_and_pos combo_merge_btn;
304
305 12 size_and_pos combo_preview;
306 12 size_and_pos combo_preview2;
307 12 size_and_pos combo_preview_text1;
308 12 size_and_pos combo_preview_text2;
309 12 size_and_pos combolist_window;
310 12 size_and_pos drawmode_btn;
311 12 size_and_pos main_panel;
312 12 size_and_pos squares_panel;
313 12 size_and_pos preview_panel;
314 12 size_and_pos layer_panel;
315 12 size_and_pos preview_text;
316
317 12 size_and_pos favorites_window;
318 12 size_and_pos favorites_list;
319 12 size_and_pos favorites_x;
320 12 size_and_pos favorites_infobtn;
321 12 size_and_pos favorites_zoombtn;
322 12 size_and_pos favorites_pgleft;
323 12 size_and_pos favorites_pgright;
324
325 12 size_and_pos commands_window;
326 12 size_and_pos commands_list;
327 12 size_and_pos commands_x;
328 12 size_and_pos commands_infobtn;
329 12 size_and_pos commands_zoombtn;
330 12 size_and_pos commands_txt;
331
332 12 size_and_pos squarepanel_swap_btn;
333 12 size_and_pos squarepanel_up_btn;
334 12 size_and_pos squarepanel_down_btn;
335 12 size_and_pos itemsqr_pos;
336 12 size_and_pos flagsqr_pos;
337 12 size_and_pos stairsqr_pos;
338 12 size_and_pos warparrival_pos;
339 12 size_and_pos warpret_pos[4];
340 12 size_and_pos enemy_prev_pos;
341
342 12 size_and_pos txtoffs_single;
343 12 size_and_pos txtoffs_double_1;
344 12 size_and_pos txtoffs_double_2;
345 int32_t panel_align = 1;
346
347 int32_t command_buttonwidth = 88;
348 int32_t command_buttonheight = 19;
349
350 int32_t layerpanel_buttonwidth = 58;
351 int32_t layerpanel_buttonheight = 16;
352
353 int32_t layerpanel_checkbox_hei = 13;
354 int32_t layerpanel_checkbox_wid = 13;
355
356 int32_t favorite_combos[MAXFAVORITECOMBOS];
357 byte favorite_combo_modes[MAXFAVORITECOMBOS];
358 bool ShowFavoriteComboModes;
359 byte FavoriteComboPage;
360
361 char comboprev_buf[512] = {0};
362 char comboprev_buf2[512] = {0};
363 FONT* txfont;
364
365 const char *roomtype_string[MAXROOMTYPES] =
366 {
367 "(None)","Special Item","Pay for Info","Secret Money","Gamble",
368 "Door Repair","Red Potion or Heart Container","Feed the Goriya","Triforce Check",
369 "Potion Shop","Shop","More Bombs","Leave Money or Life","10 Rupees",
370 "3-Stair Warp","Ganon","Zelda", "-<item pond>", "1/2 Magic Upgrade", "Learn Slash", "More Arrows","Take One Item"
371 };
372
373 const char *catchall_string[MAXROOMTYPES] =
374 {
375 "Generic Catchall","Special Item","Info Type","Amount","Generic Catchall","Repair Fee","Generic Catchall","Generic Catchall","Generic Catchall","Shop Type",
376 "Shop Type","Price","Price","Generic Catchall","Warp Ring","Generic Catchall","Generic Catchall", "Generic Catchall", "Generic Catchall",
377 "Generic Catchall", "Price","Shop Type","Bottle Shop Type"
378 };
379
380 #define MAXPOOLCOMBOS MAXFAVORITECOMBOS
381
382 struct cmbdat_pair
383 {
384 int32_t data;
385 byte cset;
386 15120 cmbdat_pair() { clear(); }
387 25200 void clear()
388 {
389 25200 data = -1;
390 25200 cset = 0;
391 25200 }
392 bool valid() const
393 {
394 return data > -1;
395 }
396 };
397 bool pool_dirty=true;
398 12 cmbdat_pair pool_combos[MAXPOOLCOMBOS];
399 static std::vector<byte> pool;
400
401 bool pool_valid()
402 {
403 if(pool_dirty)
404 {
405 pool.clear();
406 for(auto q = 0; q < MAXPOOLCOMBOS; ++q)
407 {
408 if(pool_combos[q].valid())
409 pool.push_back(q);
410 }
411 pool_dirty = false;
412 }
413 return pool.size() > 0;
414 }
415 cmbdat_pair const& get_pool_combo()
416 {
417 if(!pool_valid()) return pool_combos[0];
418 auto ind = zc_rand(pool.size()-1);
419 return pool_combos[pool.at(ind)];
420 }
421
422 int32_t mouse_scroll_h;
423
424 // 'mapscreen' refers to the area of the editor where the screen is drawn.
425 int32_t mapscreen_x, mapscreen_y, showedges, showallpanels;
426 // The scale of the entire mapscreen area. This varies based on compact/extended mode.
427 static int mapscreen_screenunit_scale;
428 // The scale of an individual screen being drawn. This is `mapscreen_screenunit_scale / Map.getViewSize()`.
429 static double mapscreen_single_scale;
430 // 4 is roughly the largest value where things render okay. Beyond that, our low bitmap resolution results in tons
431 // of downsampling. Let users go to 16 anyway.
432 static int mapscreen_num_screens_to_draw_max = 16;
433 // The valid layers for the current screen(s).
434 static bool mapscreen_valid_layers[6];
435
436 struct VisibleScreen
437 {
438 int dx, dy;
439 int xoff, yoff;
440 mapscr* scr;
441 int screen;
442 };
443 static std::vector<VisibleScreen> visible_screens;
444 static VisibleScreen* active_visible_screen = nullptr;
445
446 static void set_active_visible_screen(mapscr* scr)
447 {
448 active_visible_screen = nullptr;
449 for (auto& visible_screen : visible_screens)
450 {
451 if (visible_screen.scr == scr)
452 {
453 active_visible_screen = &visible_screen;
454 break;
455 }
456 }
457 }
458
459 static ComboPosition get_mapscreen_mouse_combo_pos()
460 {
461 int startxint = mapscreen_x+(showedges?int(16*mapscreen_single_scale):0);
462 int startyint = mapscreen_y+(showedges?int(16*mapscreen_single_scale):0);
463 int cx = (gui_mouse_x()-startxint)/(16*mapscreen_single_scale);
464 int cy = (gui_mouse_y()-startyint)/(16*mapscreen_single_scale);
465 return ComboPosition{cx, cy};
466 }
467
468 static void refresh_visible_screens()
469 {
470 int num_screens = Map.getViewSize();
471 int screen_width = mapscreenbmp->w * mapscreen_single_scale;
472 int screen_height = mapscreenbmp->h * mapscreen_single_scale;
473
474 visible_screens.clear();
475 for (int dx = 0; dx < num_screens; dx++)
476 {
477 for (int dy = 0; dy < num_screens; dy++)
478 {
479 int mx = Map.getViewScr()%16 + dx;
480 int my = Map.getViewScr()/16 + dy;
481 if (mx < 0 || mx >= 16 || my < 0 || my >= 9)
482 continue;
483
484 int screen = Map.getViewScr() + dx + dy * 16;
485 if (screen >= MAPSCRS)
486 continue;
487
488 mapscr* scr = Map.Scr(screen);
489 int offx = dx * screen_width;
490 int offy = dy * screen_height;
491 visible_screens.emplace_back(VisibleScreen{dx, dy, offx, offy, scr, screen});
492 }
493 }
494
495 for (int i = 0; i < 6; i++)
496 {
497 mapscreen_valid_layers[i] = false;
498 for (auto& vis_screen : visible_screens)
499 {
500 mapscreen_valid_layers[i] |= vis_screen.scr->layermap[i] > 0;
501 }
502 }
503 }
504
505 int32_t readsize, writesize;
506 bool fake_pack_writing=false;
507
508 int32_t showxypos_x;
509 int32_t showxypos_y;
510 int32_t showxypos_w;
511 int32_t showxypos_h;
512 int32_t showxypos_color;
513 int32_t showxypos_ffc=-1000;
514 bool showxypos_icon=false;
515
516 int32_t showxypos_cursor_x;
517 int32_t showxypos_cursor_y;
518 bool showxypos_cursor_icon=false;
519 int32_t showxypos_cursor_color;
520 bool showxypos_dummy = false;
521
522 bool canfill=true; //to prevent double-filling (which stops undos)
523 int32_t lens_hint_item[MAXITEMS][2]; //aclk, aframe
524 int32_t lens_hint_weapon[MAXWPNS][5]; //aclk, aframe, dir, x, y
525 //int32_t mode, switch_mode, orig_mode;
526 int32_t tempmode=GFX_AUTODETECT;
527 RGB_MAP zq_rgb_table;
528 COLOR_MAP trans_table, trans_table2;
529 MIDI *song=NULL;
530 BITMAP *menu1, *menu3, *mapscreenbmp, *tmp_scr, *screen2, *mouse_bmp[MOUSE_BMP_MAX][4], *mouse_bmp_1x[MOUSE_BMP_MAX][4], *icon_bmp[ICON_BMP_MAX][4], *flag_bmp[16][4], *select_bmp[2], *dmapbmp_small, *dmapbmp_large;
531 BITMAP *arrow_bmp[MAXARROWS],*brushbmp, *brushscreen; //*brushshadowbmp;
532 byte *colordata=NULL, *trashbuf=NULL;
533 itemdata *itemsbuf;
534 wpndata *wpnsbuf;
535 comboclass *combo_class_buf;
536 guydata *guysbuf;
537 item_drop_object item_drop_sets[MAXITEMDROPSETS];
538 12 newcombo curr_combo;
539 PALETTE RAMpal;
540 midi_info Midi_Info;
541 bool zq_showpal=false;
542 bool is_compact = false;
543
544 int pixeldb = 1;
545 int infobg = 1;
546 bool large_merged_combopane = false;
547 bool compact_merged_combopane = true;
548 bool large_zoomed_fav = false;
549 bool compact_zoomed_fav = true;
550 bool large_zoomed_cmd = false;
551 bool compact_zoomed_cmd = true;
552
553 bool compact_square_panels = false;
554 int compact_active_panel = 0;
555
556 int combo_col_scale = 1;
557
558 std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
559 script_data *ffscripts[NUMSCRIPTFFC];
560 script_data *itemscripts[NUMSCRIPTITEM];
561 script_data *guyscripts[NUMSCRIPTGUYS];
562 script_data *lwpnscripts[NUMSCRIPTWEAPONS];
563 script_data *ewpnscripts[NUMSCRIPTWEAPONS];
564 script_data *globalscripts[NUMSCRIPTGLOBAL];
565 script_data *genericscripts[NUMSCRIPTSGENERIC];
566 script_data *playerscripts[NUMSCRIPTHERO];
567 script_data *screenscripts[NUMSCRIPTSCREEN];
568 script_data *dmapscripts[NUMSCRIPTSDMAP];
569 script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
570 script_data *comboscripts[NUMSCRIPTSCOMBODATA];
571 script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
572
573 extern string zScript;
574 char zScriptBytes[512];
575 char zLastVer[512] = { 0 };
576 SAMPLE customsfxdata[WAV_COUNT];
577 uint8_t customsfxflag[WAV_COUNT>>3];
578 int32_t sfxdat=1;
579
580 int32_t onImport_ComboAlias();
581 int32_t onExport_ComboAlias();
582
583 void set_console_state();
584
585 void clearConsole()
586 {
587 if(!console_is_open) return;
588 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
589 zscript_coloured_console.gotoxy(0,0);
590 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
591 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZQuest Classic Logging Console\n");
592 }
593
594 void initConsole()
595 {
596 if(console_is_open) return;
597 console_is_open = 1;
598 set_console_state();
599 zscript_coloured_console.Create("ZQuest Classic Logging Console", 600, 200);
600 clearConsole();
601 }
602
603 11 void killConsole()
604 {
605
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!console_is_open) return;
606 console_is_open = 0;
607 set_console_state();
608 zscript_coloured_console.kill();
609 11 }
610
611 int toggleConsole()
612 {
613 console_is_open ? killConsole() : initConsole();
614 zc_set_config("zquest","open_debug_console",console_is_open?1:0);
615 return D_O_K;
616 }
617
618 int showHotkeys()
619 {
620 hotkeys_toggle_display(!hotkeys_is_active());
621 return D_O_K;
622 }
623
624 typedef int32_t (*intF)();
625 typedef struct command_pair
626 {
627 char name[80];
628 int32_t flags;
629 intF command;
630 } command_pair;
631
632 extern map_and_screen map_page[MAX_MAPPAGE_BTNS];
633
634 int32_t do_OpenQuest()
635 {
636 return onOpen();
637 }
638
639 int32_t do_NewQuest()
640 {
641 //clear the panel recent screen buttons to prevent crashes from invalid maps
642 for ( int32_t q = 0; q < 9; q++ )
643 {
644 map_page[q].map = 0;
645 map_page[q].screen = 0;
646 }
647 Map.setCurrMap(0);
648 Map.setCurrScr(0);
649 return onNew();
650 }
651
652 extern int CheckerCol1, CheckerCol2;
653 int32_t alignment_arrow_timer=0;
654 int32_t Flip=0,Combo=0,CSet=2,current_combolist=0,current_comboalist=0,current_cpoollist=0,current_cautolist=0,current_mappage=0;
655 int32_t Flags=0,Flag=0,menutype=(m_block);
656 int MouseScroll = 0, SavePaths = 0, CycleOn = 0, ShowGrid = 0, ShowScreenGrid = 0, ShowRegionGrid = 0, GridColor = 15, ShowCurScreenOutline = 1,
657 CmbCursorCol = 15, TilePgCursorCol = 15, CmbPgCursorCol = 15, TTipHLCol = 13,
658 TileProtection = 0, ComboProtection = 0, NoScreenPreview = 0, MMapCursorStyle = 0,
659 LayerDitherBG = -1, LayerDitherSz = 2, RulesetDialog = 0,
660 EnableTooltips = 0, TooltipsHighlight = 0, ShowFFScripts = 0, ShowSquares = 0,
661 ShowFFCs = 0, ShowInfo = 0, skipLayerWarning = 0,
662 DisableLPalShortcuts = 1, DisableCompileConsole = 0, numericalFlags = 0,
663 ActiveLayerHighlight = 0, DragCenterOfSquares = 0;
664 uint8_t InvalidBG = 0;
665 bool NoHighlightLayer0 = false;
666 int32_t FlashWarpSquare = -1, FlashWarpClk = 0; // flash the destination warp return when ShowSquares is active
667 uint8_t ViewLayer3BG = 0, ViewLayer2BG = 0;
668 int32_t window_width, window_height;
669 bool ShowFPS = false, SaveDragResize = false, DragAspect = false, SaveWinPos=false;
670 bool allowHideMouse = false;
671 double aspect_ratio = LARGE_H / double(LARGE_W);
672 int window_min_width = 0, window_min_height = 0;
673 int32_t ComboBrush = 0; //show the brush instead of the normal mouse
674 int32_t ComboBrushPause = 0; //temporarily disable the combo brush
675 int32_t FloatBrush = 0; //makes the combo brush float a few pixels up and left
676 int AutoBrush = 0; //Drag to size the brush on the combo panes
677 bool AutoBrushRevert = false; //Revert after placing
678 int LinkedScroll = 0;
679 //complete with shadow
680 int32_t OpenLastQuest = 0; //makes the program reopen the quest that was
681 //open at the time you quit
682 int32_t ShowMisalignments = 0; //makes the program display arrows over combos that are
683 //not aligned with the next screen.
684 int32_t AnimationOn = 0; //animate the combos in zquest?
685 int32_t AutoBackupRetention = 0; //use auto-backup feature? if so, how many backups (1-10) to keep
686 int32_t AutoSaveInterval = 0; //how often a timed autosave is made (not overwriting the current file)
687 int32_t UncompressedAutoSaves = 0; //should timed saves be uncompressed/encrypted?
688 int32_t KeyboardRepeatDelay = 0; //the time in milliseconds after holding down a key that the key starts to repeat
689 int32_t KeyboardRepeatRate = 0; //the time in milliseconds between each repetition of a repeated key
690
691 time_t auto_save_time_start, auto_save_time_current;
692 double auto_save_time_diff = 0;
693 int32_t AutoSaveRetention = 0; //how many autosaves of a quest to keep
694 int32_t ImportMapBias = 0; //tells what has precedence on map importing
695 int32_t BrushWidth=1, BrushHeight=1;
696 bool saved=true;
697 bool __debug=false;
698 int32_t LayerMaskInt[7]={0};
699 int32_t CurrentLayer=0;
700 int32_t DuplicateAction[4]={0};
701 int32_t OnlyCheckNewTilesForDuplicates = 0;
702 int32_t try_recovering_missing_scripts = 0;
703
704 uint8_t PreFillTileEditorPage = 0, PreFillComboEditorPage = 0;
705 int32_t DMapEditorLastMaptileUsed = 0;
706
707 /*
708 , HorizontalDuplicateAction;
709 int32_t VerticalDuplicateAction, BothDuplicateAction;
710 */
711 word msg_count = 0;
712 int32_t LeechUpdate = 0;
713 int32_t LeechUpdateTiles = 0;
714 int32_t SnapshotFormat = 0;
715 byte SnapshotScale = 0;
716
717 byte Color = 0;
718 extern int32_t jwin_pal[jcMAX];
719 int32_t gui_colorset=99;
720
721 static int32_t combo_apos=0; //currently selected combo alias
722 int32_t alias_origin=0;
723 int32_t alias_cset_mod=0;
724
725 static int32_t combo_pool_pos=0; //currently selected combo pool
726 bool weighted_cpool = true;
727 bool cpool_prev_visible = false;
728
729 static int32_t combo_auto_pos=0; //currently selected autocombo
730 byte cauto_height = 1;
731
732 bool trip=false;
733
734 int32_t fill_type=1;
735
736 bool first_save=false;
737 char *filepath,*midipath,*datapath,*imagepath,*tmusicpath,*last_timed_save;
738 string helpstr, zstringshelpstr;
739
740 ZCMUSIC *zcmusic = NULL;
741 ZCMIXER *zcmixer = NULL;
742 int32_t midi_volume = 255;
743 extern int32_t prv_mode;
744 int32_t prv_warp = 0;
745 int32_t prv_twon = 0;
746 int32_t ff_combo = 0;
747
748 int32_t Frameskip = 0, RequestedFPS = 60, zqUseWin32Proc = 1;
749 int32_t zqColorDepth = 8;
750 int32_t joystick_index=0;
751
752 11 void set_last_timed_save(char const* buf)
753 {
754
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(buf && buf[0])
755 {
756 if(buf != last_timed_save)
757 strcpy(last_timed_save, buf);
758 }
759 else
760 {
761 11 last_timed_save[0] = 0;
762 11 buf = nullptr;
763 }
764 11 zc_set_config("zquest","last_timed_save",buf);
765 11 }
766
767 void loadlvlpal(int32_t level);
768 bool get_debug()
769 {
770 return __debug;
771 //return true;
772 }
773
774 void set_debug(bool d)
775 {
776 __debug=d;
777 return;
778 }
779
780 bool handle_quit()
781 {
782 if(onExit()==D_CLOSE)
783 return (exiting_program = true);
784 return false;
785 }
786 bool handle_close_btn_quit()
787 {
788 if(close_button_quit)
789 {
790 close_button_quit=false;
791 return handle_quit();
792 }
793 return false;
794 }
795 // **** Timers ****
796
797 volatile int32_t lastfps=0;
798 volatile int32_t framecnt=0;
799 size_t cpoolbrush_index = 0;
800
801 // quest data
802 12 zquestheader header;
803 byte midi_flags[MIDIFLAGS_SIZE];
804 byte music_flags[MUSICFLAGS_SIZE];
805 byte *quest_file;
806 int32_t msg_strings_size;
807 zctune *customtunes;
808 //emusic *enhancedMusic;
809 ZCHEATS zcheats;
810 byte use_cheats;
811 byte use_tiles;
812 // Note: may not be null-terminated (must refactor writecolordata to fix).
813 char palnames[MAXLEVELS][17];
814 char zquestdat_sig[52];
815 char qstdat_str[2048];
816
817 int32_t gme_track=0;
818
819 int32_t dlevel; // just here until gamedata is properly done
820
821 12 bool bad_version(int32_t ver)
822 {
823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(ver < 0x170)
824 return true;
825
826 12 return false;
827 12 }
828
829 // These are for drawing eyeballs correctly in combo_tile.
830 zfix HeroModifiedX()
831 {
832 return gui_mouse_x() - 7;
833 }
834 zfix HeroModifiedY()
835 {
836 return gui_mouse_y() - 7;
837 }
838
839
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu import_250_menu
840 48 {
841
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&DMaps", onImport_DMaps },
842
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Table", onImport_Combos },
843
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Alias", onImport_ComboAlias },
844 };
845
846
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu import_graphics
847 180 {
848
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palettes", onImport_Pals },
849
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
850
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Tileset (&Full)", onImport_Tiles },
851
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tile Pack", onImport_Tilepack },
852
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "T&ile Pack to...", onImport_Tilepack_To },
853
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
854
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Set (Range)", onImport_Combos },
855
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo Pack (Full, 1:1)", onImport_Combopack },
856
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo Pack to... (Dest)", onImport_Combopack_To },
857
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
858
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo &Alias Pack", onImport_Comboaliaspack },
859
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo A&lias Pack to...", onImport_Comboaliaspack_To },
860
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
861
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Doorsets", onImport_Doorset },
862 };
863
864
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu import_menu
865 120 {
866
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onImport_Guys },
867
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Map", onImport_Map },
868
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&DMaps", onImport_DMaps },
869
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Strings (.tsv)", onImport_StringsTSV },
870
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "String Table (deprecated)", onImport_Msgs },
871
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
872
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Graphics", &import_graphics },
873
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
874
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2.50 (Broken)", &import_250_menu },
875 };
876
877
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu export_250_menu
878 60 {
879
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&DMaps", onExport_DMaps },
880
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Table", onExport_Combos },
881
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Alias", onExport_ComboAlias },
882
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Graphics Pack", onExport_ZGP },
883 };
884
885
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu zq_help_menu
886 36 {
887
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Editor Help", onHelp },
888
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Strings Help", onZstringshelp },
889 };
890
891
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu export_graphics
892 144 {
893
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palettes", onExport_Pals },
894
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
895
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Tileset (&Full)", onExport_Tiles },
896
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tile Pack", onExport_Tilepack },
897
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
898
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Set", onExport_Combos },
899
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo Pack", onExport_Combopack },
900
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
901
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo &Alias Pack", onExport_Comboaliaspack },
902
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
903
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Doorsets", onExport_Doorset },
904 };
905
906
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu export_menu
907 132 {
908 #ifdef _WIN32
909 { "&Package", onExport_Package },
910 #endif
911
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onExport_Guys },
912
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Map", onExport_Map },
913
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&DMaps", onExport_DMaps },
914
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
915
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Strings (.tsv)", onExport_StringsTSV },
916
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "String Table (deprecated)", onExport_Msgs },
917
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
918
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Graphics", &export_graphics },
919
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
920
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2.50 (Broken)", &export_250_menu },
921 };
922
923
924
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu recent_menu
925 132 {
926
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
927
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
928
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
929
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
930
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
931
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
932
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
933
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
934
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
935
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
936 };
937 static char rec_menu_fullpaths[10][512];
938 static char rec_menu_strs[10][64];
939
940 int32_t customOpen(char const* path);
941 void do_recent_quest(uint32_t ind)
942 {
943 if(ind > 9) return;
944 strcpy(temppath, rec_menu_fullpaths[ind]);
945 customOpen(temppath);
946 }
947 int32_t do_RecentQuest_0() { do_recent_quest(0); return D_O_K; }
948 int32_t do_RecentQuest_1() { do_recent_quest(1); return D_O_K; }
949 int32_t do_RecentQuest_2() { do_recent_quest(2); return D_O_K; }
950 int32_t do_RecentQuest_3() { do_recent_quest(3); return D_O_K; }
951 int32_t do_RecentQuest_4() { do_recent_quest(4); return D_O_K; }
952 int32_t do_RecentQuest_5() { do_recent_quest(5); return D_O_K; }
953 int32_t do_RecentQuest_6() { do_recent_quest(6); return D_O_K; }
954 int32_t do_RecentQuest_7() { do_recent_quest(7); return D_O_K; }
955 int32_t do_RecentQuest_8() { do_recent_quest(8); return D_O_K; }
956 int32_t do_RecentQuest_9() { do_recent_quest(9); return D_O_K; }
957
958 2 void refresh_recent_menu()
959 {
960 2 int32_t (*procs[10])(void) = {
961 do_RecentQuest_0, do_RecentQuest_1, do_RecentQuest_2, do_RecentQuest_3,
962 do_RecentQuest_4, do_RecentQuest_5, do_RecentQuest_6,
963 do_RecentQuest_7, do_RecentQuest_8, do_RecentQuest_9
964 };
965
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
2 static MenuItem nilitem("---",nullptr,nullopt,true);
966
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 20 times.
22 for(auto q = 0; q < 10; ++q)
967 {
968 20 MenuItem& mit = *recent_menu.at(q);
969 20 bool valid = rec_menu_fullpaths[q][0] != '-';
970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(valid)
971 mit = MenuItem(rec_menu_strs[q],procs[q]);
972 20 else mit = nilitem;
973 20 }
974 2 }
975
976 1 void load_recent_quests()
977 {
978 1 char configname[64] = "rec_qst_";
979 1 char* ptr = &configname[strlen(configname)];
980 1 char buf[512] = {0};
981
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 for(auto q = 0; q < 10; ++q)
982 {
983 10 sprintf(ptr, "%d", q); //increment the configname value
984 10 char const* qst_str = zc_get_config("recent",configname,nullptr);
985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(qst_str[0])
986 {
987 strncpy(rec_menu_fullpaths[q], qst_str, 511);
988 relativize_path(buf, rec_menu_fullpaths[q]);
989 if(strlen(buf) > 62)
990 {
991 buf[60] = buf[61] = buf[62] = '.'; //add "..." as the last 3 characters
992 }
993 strncpy(rec_menu_strs[q], buf, 63);
994 }
995 else
996 {
997 10 strcpy(rec_menu_fullpaths[q], "---");
998 10 strcpy(rec_menu_strs[q], "---");
999 }
1000 10 rec_menu_fullpaths[q][511] = 0;
1001 10 rec_menu_strs[q][63] = 0;
1002 10 }
1003 1 refresh_recent_menu();
1004 1 }
1005
1006 void write_recent_quests()
1007 {
1008 char configname[64] = "rec_qst_";
1009 char* ptr = &configname[strlen(configname)];
1010 for(auto q = 0; q < 10; ++q)
1011 {
1012 sprintf(ptr, "%d", q); //increment the configname value
1013 zc_set_config("recent",configname,(rec_menu_fullpaths[q][0]!='-') ? rec_menu_fullpaths[q] : nullptr);
1014 }
1015 }
1016
1017 void update_recent_quest(char const* path)
1018 {
1019 int32_t ind = -1;
1020 for(auto q = 0; q < 10; ++q)
1021 {
1022 if(!strcmp(path, rec_menu_fullpaths[q]))
1023 {
1024 ind = q;
1025 break;
1026 }
1027 }
1028 if(ind > -1)
1029 {
1030 for(auto q = ind; q > 0; --q)
1031 {
1032 strcpy(rec_menu_fullpaths[q], rec_menu_fullpaths[q-1]);
1033 strcpy(rec_menu_strs[q], rec_menu_strs[q-1]);
1034 }
1035 }
1036 else
1037 {
1038 int32_t free_ind = 9; //if none found, override the last index
1039 for(auto q = 0; q < 9; ++q)
1040 {
1041 if(rec_menu_fullpaths[q][0] == '-')
1042 {
1043 free_ind = q;
1044 break;
1045 }
1046 }
1047
1048 for(auto q = free_ind; q > 0; --q)
1049 {
1050 strcpy(rec_menu_fullpaths[q], rec_menu_fullpaths[q-1]);
1051 strcpy(rec_menu_strs[q], rec_menu_strs[q-1]);
1052 }
1053 }
1054 char buf[512] = {0};
1055 strcpy(rec_menu_fullpaths[0], path);
1056 relativize_path(buf, rec_menu_fullpaths[0]);
1057 if(strlen(buf) > 62)
1058 {
1059 buf[60] = buf[61] = buf[62] = '.'; //add "..." as the last 3 characters
1060 }
1061 strncpy(rec_menu_strs[0], buf, 63);
1062 refresh_recent_menu();
1063 zc_set_config("zquest",last_quest_name,path);
1064 write_recent_quests();
1065 }
1066
1067 void reload_zq_gui()
1068 {
1069 init_custom_fonts();
1070 load_size_poses();
1071 refresh_visible_screens();
1072 update_combobrush();
1073 refresh(rCLEAR|rALL);
1074 }
1075 void change_mapscr_zoom(int delta)
1076 {
1077 int num_screens = Map.getViewSize();
1078 num_screens = std::clamp(num_screens + delta, 1, mapscreen_num_screens_to_draw_max);
1079 Map.setViewSize(num_screens);
1080 std::string qst_cfg_header = qst_cfg_header_from_path(filepath);
1081 zc_set_config(qst_cfg_header.c_str(), "zoom_num_screens", Map.getViewSize());
1082 reload_zq_gui();
1083 }
1084 void toggle_is_compact()
1085 {
1086 is_compact = !is_compact;
1087 zc_set_config("ZQ_GUI","compact_mode",is_compact?1:0);
1088 reload_zq_gui();
1089 }
1090 void toggle_merged_mode()
1091 {
1092 if(is_compact)
1093 {
1094 compact_merged_combopane = !compact_merged_combopane;
1095 zc_set_config("ZQ_GUI","merge_cpane_compact",compact_merged_combopane?1:0);
1096 }
1097 else
1098 {
1099 large_merged_combopane = !large_merged_combopane;
1100 zc_set_config("ZQ_GUI","merge_cpane_large",large_merged_combopane?1:0);
1101 }
1102 reload_zq_gui();
1103 }
1104 void toggle_compact_sqr_mode()
1105 {
1106 compact_square_panels = !compact_square_panels;
1107 zc_set_config("ZQ_GUI","square_panels_compact",compact_square_panels?1:0);
1108 reload_zq_gui();
1109 }
1110 void cycle_compact_sqr(bool down)
1111 {
1112 if(!(is_compact && compact_square_panels))
1113 return;
1114 static const int num_panels = 3;
1115 if(down)
1116 compact_active_panel = (compact_active_panel+1)%num_panels;
1117 else
1118 compact_active_panel = (compact_active_panel-1+num_panels)%num_panels;
1119 reload_zq_gui();
1120 }
1121 void toggle_favzoom_mode()
1122 {
1123 if(is_compact)
1124 {
1125 compact_zoomed_fav = !compact_zoomed_fav;
1126 zc_set_config("ZQ_GUI","zoom_fav_compact",compact_zoomed_fav?1:0);
1127 }
1128 else
1129 {
1130 large_zoomed_fav = !large_zoomed_fav;
1131 zc_set_config("ZQ_GUI","zoom_fav_large",large_zoomed_fav?1:0);
1132 }
1133 reload_zq_gui();
1134 }
1135 void toggle_cmdzoom_mode()
1136 {
1137 if(is_compact)
1138 {
1139 compact_zoomed_cmd = !compact_zoomed_cmd;
1140 zc_set_config("ZQ_GUI","zoom_cmd_compact",compact_zoomed_cmd?1:0);
1141 }
1142 else
1143 {
1144 large_zoomed_cmd = !large_zoomed_cmd;
1145 zc_set_config("ZQ_GUI","zoom_cmd_large",large_zoomed_cmd?1:0);
1146 }
1147 reload_zq_gui();
1148 }
1149
1150 enum
1151 {
1152 MENUID_FILE_SAVE,
1153 MENUID_FILE_SAVEAS,
1154 MENUID_FILE_REVERT,
1155 };
1156
1157
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu file_menu
1158 156 {
1159
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&New", do_NewQuest },
1160
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Open", do_OpenQuest },
1161
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Recent", &recent_menu },
1162
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1163
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Save", onSave, MENUID_FILE_SAVE },
1164
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Save &as...", onSaveAs, MENUID_FILE_SAVEAS },
1165
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Revert", onRevert, MENUID_FILE_REVERT },
1166
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1167
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Import", &import_menu },
1168
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Export", &export_menu },
1169 #ifndef __EMSCRIPTEN__
1170
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1171
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "E&xit", handle_quit },
1172 #endif
1173 };
1174
1175 enum
1176 {
1177 MENUID_MAPS_NEXT,
1178 MENUID_MAPS_PREV,
1179 };
1180
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu maps_menu
1181 72 {
1182
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Goto Map...", onGotoMap },
1183
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Next Map", onIncMap, MENUID_MAPS_NEXT },
1184
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Previous Map", onDecMap, MENUID_MAPS_PREV },
1185
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1186
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "D&elete Map", onDeleteMap },
1187 };
1188
1189
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu misc_menu
1190 120 {
1191
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "S&ubscreens", onEditSubscreens },
1192
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Shop Types", onShopTypes },
1193
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Bottle Types", onBottleTypes },
1194
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Bottle S&hop Types", onBottleShopTypes },
1195
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Info Types", onInfoTypes },
1196
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Warp Rings", onWarpRings },
1197
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Triforce Pieces", onTriPieces },
1198
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&End String", onEndString },
1199
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Item &Drop Sets", onItemDropSets },
1200 };
1201
1202
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu spr_menu
1203 48 {
1204
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Sprite Data", onCustomWpns },
1205
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Hero", onCustomHero },
1206
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Misc Sprites", onMiscSprites },
1207 };
1208
1209
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 NewMenu colors_menu
1210 48 {
1211
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Main ", onColors_Main },
1212
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Levels ", onColors_Levels },
1213
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Sprites ", onColors_Sprites },
1214 };
1215
1216
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu defs_menu
1217 108 {
1218
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palettes", onDefault_Pals },
1219
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tiles", onDefault_Tiles },
1220
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combos", onDefault_Combos },
1221
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Items", onDefault_Items },
1222
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onDefault_Guys },
1223
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Sprite Data", onDefault_Weapons },
1224
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Map Styles", onDefault_MapStyles },
1225
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "SF&X Data", onDefault_SFX },
1226 };
1227
1228 int32_t onEditComboAlias();
1229 int32_t onEditComboPool();
1230 int32_t onEditAutoCombo();
1231
1232
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu graphics_menu
1233 120 {
1234
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palettes ", &colors_menu },
1235
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Sprites ", &spr_menu },
1236
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combos", onCombos },
1237
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tiles", onTiles },
1238
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Game icons", onIcons },
1239
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Misc co&lors", onMiscColors },
1240
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Map styles", onMapStyles },
1241
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Door Combo Sets", onDoorCombos },
1242
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo &Aliases", onEditComboAlias },
1243 };
1244
1245
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu audio_menu
1246 48 {
1247
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "SF&X Data", onSelectSFX },
1248
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&MIDIs", onMidis },
1249
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Mis&c SFX", onMiscSFX },
1250 };
1251
1252 void set_rules(byte* newrules);
1253
1254 void call_testqst_dialog();
1255 int32_t onTestQst()
1256 {
1257 call_testqst_dialog();
1258 return D_O_K;
1259 }
1260
1261 int32_t onRulesDlg()
1262 {
1263 call_qr_dialog(21, set_rules);
1264 return D_O_K;
1265 }
1266
1267 int32_t onRulesSearch()
1268 {
1269 call_qrsearch_dialog(set_rules);
1270 return D_O_K;
1271 }
1272
1273 int32_t onZScriptSettings()
1274 {
1275 ScriptRulesDialog(quest_rules, 17, [](byte* newrules)
1276 {
1277 saved = false;
1278 memcpy(quest_rules, newrules, QR_SZ);
1279 unpack_qrs();
1280 }).show();
1281 return D_O_K;
1282 }
1283
1284 void call_zinf_dlg();
1285 int32_t onZInfo()
1286 {
1287 call_zinf_dlg();
1288 return D_O_K;
1289 }
1290
1291
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu quest_menu
1292 204 {
1293
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Options ", onRulesDlg },
1294
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Test", onTestQst },
1295
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Items", onCustomItems },
1296
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Ene&mies", onCustomEnemies },
1297
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Hero", onCustomHero },
1298
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Strings", onStrings },
1299
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&DMaps", onDmaps },
1300
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Regions", onRegions },
1301
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "I&nit Data", onInit },
1302
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Misc D&ata ", &misc_menu },
1303
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&ZInfo", onZInfo },
1304
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1305
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Graphics ", &graphics_menu },
1306
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "A&udio ", &audio_menu },
1307
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1308
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "De&faults ", &defs_menu },
1309 };
1310
1311
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu paste_menu
1312 36 {
1313
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste &To All", onPasteToAll },
1314
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste &All To All", onPasteAllToAll },
1315 };
1316
1317
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu paste_item_menu
1318 156 {
1319
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Undercombo", onPasteUnderCombo },
1320
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Secret Combos", onPasteSecretCombos },
1321
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Freeform Combos", onPasteFFCombos },
1322
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Screen &Data", onPasteScreenData },
1323
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Warps", onPasteWarps },
1324
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Warp &Return", onPasteWarpLocations },
1325
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onPasteEnemies },
1326
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Room &Type Data", onPasteRoom },
1327
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Guy/String", onPasteGuy },
1328
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Doo&rs", onPasteDoors },
1329
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Layers", onPasteLayers },
1330
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palette", onPastePalette },
1331 };
1332
1333 enum
1334 {
1335 MENUID_EDIT_UNDO,
1336 MENUID_EDIT_REDO,
1337 MENUID_EDIT_COPY,
1338 MENUID_EDIT_PASTE,
1339 MENUID_EDIT_PASTEALL,
1340 MENUID_EDIT_ADVPASTE,
1341 MENUID_EDIT_SPECPASTE,
1342 MENUID_EDIT_DELETE,
1343 };
1344
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu edit_menu
1345 132 {
1346
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Undo", onUndo, MENUID_EDIT_UNDO },
1347
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Redo", onRedo, MENUID_EDIT_REDO },
1348
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Copy", onCopy, MENUID_EDIT_COPY },
1349
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Paste", onPaste, MENUID_EDIT_PASTE },
1350
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste A&ll", onPasteAll, MENUID_EDIT_PASTEALL },
1351
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Adv. Paste ", &paste_menu, MENUID_EDIT_ADVPASTE },
1352
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste &Spec. ", &paste_item_menu, MENUID_EDIT_SPECPASTE },
1353
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Delete", onDelete, MENUID_EDIT_DELETE },
1354
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1355
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Maps ", &maps_menu },
1356 };
1357
1358
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu drawing_mode_menu
1359 60 {
1360
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Normal", onDrawingModeNormal, dm_normal },
1361
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Alias", onDrawingModeAlias, dm_alias },
1362
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Pool", onDrawingModePool, dm_cpool },
1363
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Auto Combo", onDrawingModeAuto, dm_auto },
1364 };
1365
1366
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu integrity_check_menu
1367 48 {
1368
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&All ", onIntegrityCheckAll },
1369
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Screens ", onIntegrityCheckRooms },
1370
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Warps ", onIntegrityCheckWarps },
1371 };
1372
1373
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu quest_reports_menu
1374 108 {
1375
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Bugged Next-> Combo Locations", onBuggedNextComboLocationReport },
1376
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Locations", onComboLocationReport },
1377
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Type Locations", onComboTypeLocationReport },
1378
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemy Locations", onEnemyLocationReport },
1379
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Item Locations", onItemLocationReport },
1380
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Script Locations", onScriptLocationReport },
1381
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&What Links Here", onWhatWarpsReport },
1382
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "In&tegrity Check ", &integrity_check_menu },
1383 };
1384
1385 int32_t onPalFix();
1386 int32_t onPitFix();
1387 int32_t onStrFix()
1388 {
1389 if(get_qr(qr_OLD_STRING_EDITOR_MARGINS))
1390 {
1391 AlertDialog("Fix: Old Margins",
1392 "Fixing margins may cause strings that used to spill outside the textbox"
1393 " to instead be cut off. Are you sure?",
1394 [&](bool ret,bool)
1395 {
1396 if(ret)
1397 {
1398 set_qr(qr_OLD_STRING_EDITOR_MARGINS, 0);
1399 saved = false;
1400 }
1401 }).show();
1402 }
1403 if(get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT))
1404 {
1405 AlertDialog("Fix: Old Frame Size",
1406 "This will fix the frame size of all strings. No visual changes should occur,"
1407 " as the string width/height will be fixed, but the compat QR will also be unchecked.",
1408 [&](bool ret,bool)
1409 {
1410 if(ret)
1411 {
1412 for(auto q = 0; q < msg_count; ++q)
1413 {
1414 MsgStrings[q].w += 16;
1415 MsgStrings[q].h += 16;
1416 }
1417 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT, 0);
1418 saved = false;
1419 }
1420 }).show();
1421 }
1422 return D_O_K;
1423 }
1424
1425 int32_t onRemoveOldArrivalSquare();
1426 enum
1427 {
1428 MENUID_FIXTOOL_OLDSTRING,
1429 };
1430
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu fixtools_menu
1431 96 {
1432
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Color Set Fix", onCSetFix },
1433
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Liquid Solidity Fix", onWaterSolidity },
1434
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Effect Square Fix", onEffectFix },
1435
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Level Palette Fix", onPalFix },
1436
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Pit and Liquid Damage Fix", onPitFix },
1437
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Old Strings Fix", onStrFix, MENUID_FIXTOOL_OLDSTRING },
1438
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Green Arrival Square Fix", onRemoveOldArrivalSquare },
1439 };
1440
1441
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu tool_menu
1442 132 {
1443
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo &Flags", onFlags, nullopt, MFL_EXIT_PRE_PROC },
1444
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Fix &Tools ", &fixtools_menu },
1445
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&NES Dungeon Template", onTemplate },
1446
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Apply Template to All", onReTemplate },
1447
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1448
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Preview Mode", onPreviewMode },
1449
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Drawing &Mode ", &drawing_mode_menu },
1450
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1451
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&List Combos Used", onUsedCombos },
1452
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Quest Reports ", &quest_reports_menu },
1453 };
1454
1455 int32_t onLayer3BG()
1456 {
1457 ViewLayer3BG = ViewLayer3BG ? 0 : 1;
1458 zc_set_config("zquest","layer3_bg",ViewLayer3BG);
1459 return D_O_K;
1460 }
1461 int32_t onLayer2BG()
1462 {
1463 ViewLayer2BG = ViewLayer2BG ? 0 : 1;
1464 zc_set_config("zquest","layer2_bg",ViewLayer2BG);
1465 return D_O_K;
1466 }
1467 int onGridToggle();
1468 enum
1469 {
1470 MENUID_VIEW_WALKABILITY,
1471 MENUID_VIEW_FLAGS,
1472 MENUID_VIEW_CSET,
1473 MENUID_VIEW_TYPES,
1474 MENUID_VIEW_INFO,
1475 MENUID_VIEW_SQUARES,
1476 MENUID_VIEW_FFCS,
1477 MENUID_VIEW_SCRIPTNAMES,
1478 MENUID_VIEW_GRID,
1479 MENUID_VIEW_SCREENGRID,
1480 MENUID_VIEW_REGIONGRID,
1481 MENUID_VIEW_CURSCROUTLINE,
1482 MENUID_VIEW_DARKNESS,
1483 MENUID_VIEW_L2BG,
1484 MENUID_VIEW_L3BG,
1485 MENUID_VIEW_LAYERHIGHLIGHT,
1486 };
1487
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 NewMenu view_menu
1488 252 {
1489
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "View &Map...", onViewMap },
1490
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "View &Palette", onShowPal },
1491
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1492
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Walkability", onShowWalkability, MENUID_VIEW_WALKABILITY },
1493
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Flags", onShowFlags, MENUID_VIEW_FLAGS },
1494
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &CSets", onShowCSet, MENUID_VIEW_CSET },
1495
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Types", onShowCType, MENUID_VIEW_TYPES },
1496
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1497
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show Screen &Info", onToggleShowInfo, MENUID_VIEW_INFO },
1498
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Squares", onToggleShowSquares, MENUID_VIEW_SQUARES },
1499
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show FFCs", onToggleShowFFCs, MENUID_VIEW_FFCS },
1500
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show Script &Names", onToggleShowScripts, MENUID_VIEW_SCRIPTNAMES },
1501
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Grid", onGridToggle, MENUID_VIEW_GRID },
1502
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show Screen G&rid", onToggleScreenGrid, MENUID_VIEW_SCREENGRID },
1503
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show Region Grid", onToggleRegionGrid, MENUID_VIEW_REGIONGRID },
1504
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show Current Screen Outline", onToggleCurrentScreenOutline, MENUID_VIEW_CURSCROUTLINE },
1505
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Darkness", onShowDarkness, MENUID_VIEW_DARKNESS },
1506
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Layer 2 is Background", onLayer2BG, MENUID_VIEW_L2BG },
1507
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Layer 3 is Background", onLayer3BG, MENUID_VIEW_L3BG },
1508
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Highlight Current Layer", onToggleHighlightLayer, MENUID_VIEW_LAYERHIGHLIGHT },
1509 };
1510
1511 11 void set_rules(byte* newrules)
1512 {
1513 11 saved = false;
1514
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(newrules != quest_rules)
1515 memcpy(quest_rules, newrules, QR_SZ);
1516 11 unpack_qrs();
1517
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
11 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
1518 {
1519 2 combobuf[0].walk = 0xF0;
1520 2 combobuf[0].type = 0;
1521 2 combobuf[0].flag = 0;
1522 2 }
1523
1524 // For 2.50.0 and 2.50.1
1525
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
11 if(get_qr(qr_VERYFASTSCROLLING))
1526 2 set_qr(qr_FASTDNGN, 1);
1527 11 }
1528
1529 int32_t onSelectFFCombo();
1530
1531 void onScreenNotes()
1532 {
1533 edit_screen_notes(Map.CurrScr(), Map.getCurrMap(), Map.getCurrScr());
1534 }
1535
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu data_menu
1536 216 {
1537
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Screen Data", onScrData },
1538
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Freeform Combos", onSelectFFCombo },
1539
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "La&yers", onLayers },
1540
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tile Warp", onTileWarp },
1541
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Side &Warp", onSideWarp },
1542
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Secret &Combos", onSecretCombo },
1543
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Under Combo", onUnderCombo },
1544
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Doors", onDoors },
1545
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Maze Path", onPath },
1546
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1547
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Item", onItem },
1548
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onEnemies },
1549
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palette", onScreenPalette },
1550
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1551
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Room Data", onRoom },
1552
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Notes", onScreenNotes },
1553
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Browse Notes", browse_screen_notes },
1554 };
1555
1556
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu tunes_menu
1557 252 {
1558
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "ZC Forever", playZCForever },
1559
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Wind Fish", playTune1 },
1560
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Overworld", playTune2 },
1561
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Hyrule Castle", playTune3 },
1562
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Lost Woods", playTune4 },
1563
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Great Sea", playTune5 },
1564
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "East Hyrule", playTune6 },
1565
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Dancing Dragon", playTune7 },
1566
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Stone Tower", playTune8 },
1567
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Villages", playTune9 },
1568
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Swamp + Desert", playTune10 },
1569
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Outset Island", playTune11 },
1570
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Kakariko Village", playTune12 },
1571
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Clock Town", playTune13 },
1572
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Temple", playTune14 },
1573
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Dark World", playTune15 },
1574
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Dragon Roost", playTune16 },
1575
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Horse Race", playTune17 },
1576
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Credits", playTune18 },
1577
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Zelda's Lullaby", playTune19 },
1578 };
1579
1580 enum
1581 {
1582 MENUID_MEDIA_TUNES,
1583 MENUID_MEDIA_PLAYMUSIC,
1584 MENUID_MEDIA_CHANGETRACK,
1585 };
1586
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu media_menu
1587 60 {
1588
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Ambient Music ", &tunes_menu, MENUID_MEDIA_TUNES },
1589
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Play music", playMusic, MENUID_MEDIA_PLAYMUSIC },
1590
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Change track", changeTrack, MENUID_MEDIA_CHANGETRACK },
1591
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Stop tunes", stopMusic },
1592 };
1593
1594 enum
1595 {
1596 MENUID_ETC_VIDMODE,
1597 MENUID_ETC_FULLSCREEN,
1598 MENUID_ETC_DEBUG_CONSOLE,
1599 };
1600
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu etc_menu
1601 192 {
1602
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Help", &zq_help_menu },
1603
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&About", onAbout },
1604
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Video Mode", onZQVidMode, MENUID_ETC_VIDMODE },
1605
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Options...", onOptions },
1606
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Hotkeys...", do_zq_hotkey_dialog },
1607
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&List Hotkeys...", do_zq_list_hotkeys_dialog },
1608
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Fullscreen", onFullScreen, MENUID_ETC_FULLSCREEN },
1609
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1610
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&View Pic...", onViewPic },
1611
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Media", &media_menu },
1612
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1613
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Debug Console", toggleConsole, MENUID_ETC_DEBUG_CONSOLE },
1614
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Clear Quest Filepath", onClearQuestFilepath },
1615
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Take ZQ Snapshot", onMenuSnapshot },
1616
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Take &Screen Snapshot", onMapscrSnapshot },
1617 };
1618
1619
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu zscript_menu
1620 60 {
1621
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Compile &ZScript...", onCompileScript },
1622
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1623
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Compiler Settings", onZScriptCompilerSettings },
1624
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Quest Script Settings", onZScriptSettings },
1625 };
1626
1627 void set_console_state()
1628 {
1629 etc_menu.select_uid(MENUID_ETC_DEBUG_CONSOLE, console_is_open);
1630 }
1631
1632
3/16
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
12 NewMenu foo_menu{{"FOO",[](){InfoDialog("PLACEHOLDER","THIS IS A PLACEHOLDER").show();}}};
1633
1634
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 TopMenu the_menu
1635 108 {
1636
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&File", &file_menu },
1637
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Quest", &quest_menu },
1638
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Edit", &edit_menu },
1639
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&View", &view_menu },
1640
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tools", &tool_menu },
1641
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Screen", &data_menu },
1642
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&ZScript", &zscript_menu },
1643
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Et&C", &etc_menu },
1644 };
1645
1646 void rebuild_trans_table();
1647 int32_t launchPicViewer(BITMAP **pictoview, PALETTE pal,
1648 int32_t *px2, int32_t *py2, double *scale, bool isviewingmap, bool skipmenu = false);
1649
1650 int32_t onResetTransparency()
1651 {
1652 restore_mouse();
1653 rebuild_trans_table();
1654 jwin_alert("Notice","Translucency Table Rebuilt",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
1655
1656 refresh(rALL);
1657 return D_O_K;
1658 }
1659
1660 int32_t onFullScreen()
1661 {
1662 get_palette(RAMpal);
1663 bool windowed=is_windowed_mode()!=0;
1664 all_toggle_fullscreen(windowed);
1665
1666 gui_mouse_focus=0;
1667 gui_bg_color=jwin_pal[jcBOX];
1668 gui_fg_color=jwin_pal[jcBOXFG];
1669 MouseSprite::set(ZQM_NORMAL);
1670 zc_set_palette(RAMpal);
1671 position_mouse(zq_screen_w/2,zq_screen_h/2);
1672 set_display_switch_mode(SWITCH_BACKGROUND);
1673 set_display_switch_callback(SWITCH_OUT, switch_out);
1674 set_display_switch_callback(SWITCH_IN, switch_in);
1675 zc_set_config("zquest","fullscreen", is_windowed_mode() ? 0 : 1);
1676 return D_REDRAW;
1677 }
1678
1679 int32_t onEnter()
1680 {
1681 if(key[KEY_ALT]||key[KEY_ALTGR])
1682 {
1683 return onFullScreen();
1684 }
1685
1686 return D_O_K;
1687 }
1688
1689 //PROC, x, y, w, h, fg, bg, key, flags, d1, d2, *dp, *dp2, *dp3
1690
1691 //*text, (*proc), *child, flags, *dp
1692
1693 void run_zq_frame();
1694 int32_t d_nbmenu_proc(int32_t msg,DIALOG *d,int32_t c);
1695
1696
1697 /*int32_t onY()
1698 {
1699 return D_O_K;
1700 }*/
1701
1702 int32_t onToggleGrid(bool color)
1703 {
1704 if(color)
1705 {
1706 GridColor=(GridColor+8)%16;
1707 zc_set_config("zquest", "grid_color", GridColor);
1708 }
1709 else
1710 {
1711 ShowGrid=!ShowGrid;
1712 zc_set_config("zquest","show_grid",ShowGrid);
1713 }
1714
1715 return D_O_K;
1716 }
1717
1718 int onGridToggle()
1719 {
1720 return onToggleGrid(CHECK_CTRL_CMD);
1721 }
1722
1723 int32_t onToggleScreenGrid()
1724 {
1725 ShowScreenGrid=!ShowScreenGrid;
1726 zc_set_config("zquest","show_screen_grid",ShowScreenGrid);
1727 return D_O_K;
1728 }
1729
1730 int32_t onToggleRegionGrid()
1731 {
1732 ShowRegionGrid=!ShowRegionGrid;
1733 zc_set_config("zquest","show_region_grid",ShowRegionGrid);
1734 return D_O_K;
1735 }
1736
1737 int32_t onToggleCurrentScreenOutline()
1738 {
1739 ShowCurScreenOutline=!ShowCurScreenOutline;
1740 zc_set_config("zquest","show_current_screen_outline",ShowCurScreenOutline);
1741 return D_O_K;
1742 }
1743
1744 int32_t onToggleShowScripts()
1745 {
1746 ShowFFScripts=!ShowFFScripts;
1747 zc_set_config("zquest","showffscripts",ShowFFScripts);
1748 return D_O_K;
1749 }
1750
1751 int32_t onToggleShowFFCs()
1752 {
1753 ShowFFCs=!ShowFFCs;
1754 zc_set_config("zquest","showffcs",ShowFFCs);
1755 return D_O_K;
1756 }
1757
1758 int32_t onToggleShowSquares()
1759 {
1760 ShowSquares=!ShowSquares;
1761 zc_set_config("zquest","showsquares",ShowSquares);
1762 return D_O_K;
1763 }
1764
1765 int32_t onToggleShowInfo()
1766 {
1767 ShowInfo=!ShowInfo;
1768 zc_set_config("zquest","showinfo",ShowInfo);
1769 return D_O_K;
1770 }
1771
1772 int32_t onToggleHighlightLayer()
1773 {
1774 ActiveLayerHighlight = ActiveLayerHighlight ? 0 : 1;
1775 zc_set_config("zquest","hl_active_lyr",ActiveLayerHighlight);
1776 return D_O_K;
1777 }
1778
1779 int onKeySlash()
1780 {
1781 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
1782 {
1783 onAbout();
1784 }
1785 return D_O_K;
1786 }
1787
1788 int onAKey()
1789 {
1790 if(prv_mode)
1791 Map.set_prvadvance(1);
1792 return D_O_K;
1793 }
1794
1795 int onReloadPreview()
1796 {
1797 if(prv_mode)
1798 {
1799 Map.set_prvscr(Map.get_prv_map(), Map.get_prv_scr());
1800 Map.set_prvcmb(0);
1801 }
1802 return D_O_K;
1803 }
1804 int onSecretsPreview()
1805 {
1806 if(prv_mode)
1807 {
1808 Map.prv_secrets(false);
1809 refresh(rALL);
1810 }
1811 return D_O_K;
1812 }
1813
1814 int onSKey()
1815 {
1816 if(CHECK_CTRL_CMD)
1817 {
1818 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
1819 {
1820 onSaveAs();
1821 }
1822 else
1823 {
1824 if(!saved)
1825 onSave();
1826 }
1827 }
1828 else if(prv_mode)
1829 {
1830 Map.prv_secrets(false);
1831 refresh(rALL);
1832 }
1833 else onStrings();
1834 return D_O_K;
1835 }
1836 int onSetNewLayer(int newlayer)
1837 {
1838 CurrentLayer = newlayer;
1839 refresh(rALL);
1840 return D_O_K;
1841 }
1842 void lpal_dsa()
1843 {
1844 info_dsa("Level Palette Shortcuts",
1845 "You currently have level palette shortcuts disabled."
1846 " These can be re-enabled in 'Etc->Options', on the toggle 'Disable Level Palette Shortcuts'.",
1847 "dsa_lpal");
1848 }
1849 int onScreenLPal(int lpal)
1850 {
1851 if(DisableLPalShortcuts)
1852 {
1853 lpal_dsa();
1854 return D_O_K;
1855 }
1856 saved=false;
1857 Map.setcolor(lpal);
1858 refresh(rSCRMAP);
1859 return D_O_K;
1860 }
1861
1862 int32_t onPressEsc()
1863 {
1864 if(zoomed_minimap)
1865 mmap_set_zoom(false);
1866 else return onExit();
1867 return D_O_K;
1868 }
1869
1870 static DIALOG dialogs[] =
1871 {
1872 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
1873 { d_nbmenu_proc, 0, 0, 0, 13, 0, 0, 0, D_USER, 0, 0, (void *) &the_menu, NULL, NULL },
1874 { d_zq_hotkey_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1875
1876 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
1877 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_ESC, 0, (void *) onPressEsc, NULL, NULL },
1878 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, (void *) onUsedCombos, NULL, NULL },
1879 { d_vsync_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1880 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1881 };
1882
1883
1884 int32_t onDecColour()
1885 {
1886 if ( CHECK_CTRL_CMD )
1887 {
1888 return onDecScrPal16();
1889 }
1890
1891 else if ( key[KEY_LSHIFT] || key[KEY_RSHIFT] )
1892 {
1893 return onDecScrPal();
1894 }
1895
1896 else
1897 {
1898 return onDecreaseCSet();
1899 }
1900 }
1901
1902 int32_t onIncColour()
1903 {
1904
1905 if ( CHECK_CTRL_CMD )
1906 {
1907 return onIncScrPal16();
1908 }
1909
1910 else if ( key[KEY_LSHIFT] || key[KEY_RSHIFT] )
1911 {
1912 return onIncScrPal();
1913 }
1914
1915 else
1916 {
1917 return onIncreaseCSet();
1918 }
1919 }
1920
1921 static DIALOG getnum_dlg[] =
1922 {
1923 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
1924 12 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
1925 12 { jwin_rtext_proc, 114, 104+4, 48, 8, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, (void *) "Value:", NULL, NULL },
1926 12 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
1927 12 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
1928 12 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
1929 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1930 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1931 };
1932
1933 int32_t getnumber(const char *prompt,int32_t initialval)
1934 {
1935 cancelgetnum=true;
1936 char buf[20];
1937 sprintf(buf,"%d",initialval);
1938 getnum_dlg[0].dp=(void *)prompt;
1939 getnum_dlg[0].dp2=get_zc_font(font_lfont);
1940 getnum_dlg[2].dp=(void *)buf;
1941
1942 large_dialog(getnum_dlg);
1943
1944 int32_t ret=do_zqdialog(getnum_dlg,2);
1945
1946 if(ret!=0&&ret!=4)
1947 {
1948 cancelgetnum=false;
1949 }
1950
1951 if(ret==3)
1952 return atoi(buf);
1953
1954 return initialval;
1955 }
1956
1957 static DIALOG save_tiles_dlg[] =
1958 {
1959 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
1960
1961
1962 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Tile Pack", NULL, NULL },
1963 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1964 //for future tabs
1965 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1966 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1967 //4
1968 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
1969 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
1970 //6
1971 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
1972 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
1973 //8
1974 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
1975 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
1976 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1977 };
1978
1979
1980 void savesometiles(const char *prompt,int32_t initialval)
1981 {
1982
1983 char firsttile[8], tilecount[8];
1984 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
1985 sprintf(firsttile,"%d",0);
1986 sprintf(tilecount,"%d",1);
1987 //int32_t ret;
1988
1989
1990
1991 save_tiles_dlg[0].dp2 = get_zc_font(font_lfont);
1992
1993 sprintf(firsttile,"%d",0);
1994 sprintf(tilecount,"%d",1);
1995
1996 save_tiles_dlg[5].dp = firsttile;
1997 save_tiles_dlg[7].dp = tilecount;
1998
1999 large_dialog(save_tiles_dlg);
2000
2001 int32_t ret = do_zqdialog(save_tiles_dlg,-1);
2002 jwin_center_dialog(save_tiles_dlg);
2003
2004 if(ret == 8)
2005 {
2006 first_tile_id = vbound(atoi(firsttile), 0, NEWMAXTILES);
2007 the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2008 if(prompt_for_new_file_compat("Save ZTILE(.ztile)", "ztile", NULL,datapath,false))
2009 {
2010 char name[PATH_MAX];
2011 extract_name(temppath,name,FILENAMEALL);
2012 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2013 if(f)
2014 {
2015 writetilefile(f,first_tile_id,the_tile_count);
2016 pack_fclose(f);
2017 char tmpbuf[PATH_MAX+20]={0};
2018 sprintf(tmpbuf,"Saved %s",name);
2019 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2020 }
2021 }
2022 }
2023 }
2024
2025 static DIALOG read_tiles_dlg[] =
2026 {
2027 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2028
2029
2030 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load Tilepack To:", NULL, NULL },
2031 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2032 //for future tabs
2033 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2034 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2035 //4
2036 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2037 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2038 //6
2039 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2040 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2041 //8
2042 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2043 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2044 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2045 };
2046
2047
2048 void writesometiles_to(const char *prompt,int32_t initialval)
2049 {
2050
2051 char firsttile[8];;
2052 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2053 sprintf(firsttile,"%d",0);
2054 //int32_t ret;
2055
2056
2057
2058 read_tiles_dlg[0].dp2 = get_zc_font(font_lfont);
2059
2060 sprintf(firsttile,"%d",0);
2061 //sprintf(tilecount,"%d",1);
2062
2063 read_tiles_dlg[5].dp = firsttile;
2064
2065 large_dialog(read_tiles_dlg);
2066
2067 int32_t ret = do_zqdialog(read_tiles_dlg,-1);
2068 jwin_center_dialog(read_tiles_dlg);
2069
2070 if(ret == 8)
2071 {
2072 first_tile_id = vbound(atoi(firsttile), 0, NEWMAXTILES);
2073 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2074 if(prompt_for_existing_file_compat("Load ZTILE(.ztile)", "ztile", NULL,datapath,false))
2075 {
2076
2077 char name[256];
2078 extract_name(temppath,name,FILENAMEALL);
2079 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2080 if(f)
2081 {
2082
2083 if (!readtilefile_to_location(f,first_tile_id))
2084 {
2085 al_trace("Could not read from .ztile packfile %s\n", name);
2086 jwin_alert("ZTILE File: Error","Could not load the specified Tile.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2087 }
2088 else
2089 {
2090 jwin_alert("ZTILE File: Success!","Loaded the source tiles to your tile sheets!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2091 }
2092 pack_fclose(f);
2093 }
2094 }
2095 }
2096 }
2097
2098
2099 static DIALOG save_combofiles_dlg[] =
2100 {
2101 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2102
2103
2104 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Combo Pack", NULL, NULL },
2105 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2106 //for future tabs
2107 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2108 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2109 //4
2110 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2111 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2112 //6
2113 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2114 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2115 //8
2116 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2117 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2118 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2119 };
2120
2121
2122 void savesomecombos(const char *prompt,int32_t initialval)
2123 {
2124
2125 char firsttile[8], tilecount[8];
2126 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2127 sprintf(firsttile,"%d",0);
2128 sprintf(tilecount,"%d",1);
2129 //int32_t ret;
2130
2131
2132
2133 save_combofiles_dlg[0].dp2 = get_zc_font(font_lfont);
2134
2135 sprintf(firsttile,"%d",0);
2136 sprintf(tilecount,"%d",1);
2137
2138 save_combofiles_dlg[5].dp = firsttile;
2139 save_combofiles_dlg[7].dp = tilecount;
2140
2141 large_dialog(save_combofiles_dlg);
2142
2143 int32_t ret = do_zqdialog(save_combofiles_dlg,-1);
2144 jwin_center_dialog(save_combofiles_dlg);
2145
2146 if(ret == 8)
2147 {
2148 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2149 the_tile_count = vbound(atoi(tilecount), 1, (MAXCOMBOS-1)-first_tile_id);
2150 if(prompt_for_new_file_compat("Save ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2151 {
2152 char name[PATH_MAX];
2153 extract_name(temppath,name,FILENAMEALL);
2154 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2155 if(f)
2156 {
2157 writecombofile(f,first_tile_id,the_tile_count);
2158 pack_fclose(f);
2159 char tmpbuf[PATH_MAX+20]={0};
2160 sprintf(tmpbuf,"Saved %s",name);
2161 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2162 }
2163 }
2164 }
2165 }
2166
2167
2168 static DIALOG load_comboset_dlg[] =
2169 {
2170 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2171
2172
2173 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combo Set (Range)", NULL, NULL },
2174 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2175 //for future tabs
2176 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2177 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2178 //4
2179 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First:", NULL, NULL },
2180 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2181 //6
2182 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2183 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2184 //8
2185 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2186 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2187 { jwin_check_proc, 10, 46, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2188
2189 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2190 };
2191
2192 void writesomecombos(const char *prompt,int32_t initialval)
2193 {
2194
2195 char firsttile[8];
2196 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2197 sprintf(firsttile,"%d",0);
2198 //int32_t ret;
2199
2200
2201
2202 load_comboset_dlg[0].dp2 = get_zc_font(font_lfont);
2203
2204 sprintf(firsttile,"%d",0);
2205 //sprintf(tilecount,"%d",1);
2206
2207 load_comboset_dlg[5].dp = firsttile;
2208
2209 byte nooverwrite = 0;
2210
2211
2212 large_dialog(load_comboset_dlg);
2213
2214 int32_t ret = do_zqdialog(load_comboset_dlg,-1);
2215 jwin_center_dialog(load_comboset_dlg);
2216
2217 if(ret == 8)
2218 {
2219 if (load_comboset_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2220
2221 al_trace("Nooverwrite is: %d\n", nooverwrite);
2222 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2223 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2224 if(prompt_for_existing_file_compat("Load ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2225 {
2226 char name[256];
2227 extract_name(temppath,name,FILENAMEALL);
2228 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2229 if(f)
2230 {
2231
2232 if (!readcombofile(f,first_tile_id,nooverwrite))
2233 {
2234 al_trace("Could not read from .zcombo packfile %s\n", name);
2235 jwin_alert("ZCOMBO File: Error","Could not load the specified combos.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2236 }
2237 else
2238 {
2239 jwin_alert("ZCOMBO File: Success!","Loaded the source combos to your combo pages!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2240 saved=false;
2241 }
2242 pack_fclose(f);
2243 }
2244
2245 }
2246 }
2247 }
2248
2249 static DIALOG load_combopack_dlg[] =
2250 {
2251 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2252
2253
2254 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Import Full Combo Package 1:1", NULL, NULL },
2255 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2256 //for future tabs
2257 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2258 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2259 //4
2260 { d_dummy_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2261 { d_dummy_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2262 //6
2263 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2264 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2265 //8
2266 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2267 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2268 { jwin_check_proc, 10, 42, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2269
2270 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2271 };
2272
2273 void loadcombopack(const char *prompt,int32_t initialval)
2274 {
2275
2276 char firsttile[8];
2277 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2278 sprintf(firsttile,"%d",0);
2279 //int32_t ret;
2280
2281
2282
2283 load_combopack_dlg[0].dp2 = get_zc_font(font_lfont);
2284
2285 sprintf(firsttile,"%d",0);
2286 //sprintf(tilecount,"%d",1);
2287
2288 load_combopack_dlg[5].dp = firsttile;
2289
2290 byte nooverwrite = 0;
2291
2292
2293 large_dialog(load_combopack_dlg);
2294
2295 int32_t ret = do_zqdialog(load_combopack_dlg,-1);
2296 jwin_center_dialog(load_combopack_dlg);
2297
2298 if(ret == 8)
2299 {
2300 if (load_combopack_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2301
2302 al_trace("Nooverwrite is: %d\n", nooverwrite);
2303 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2304 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2305 if(prompt_for_existing_file_compat("Load ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2306 {
2307 char name[256];
2308 extract_name(temppath,name,FILENAMEALL);
2309 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2310 if(f)
2311 {
2312 //need dialogue here
2313 if (!readcombofile(f,0,nooverwrite))
2314 {
2315 al_trace("Could not read from .zcombo packfile %s\n", name);
2316 jwin_alert("ZCOMBO File: Error","Could not load the specified Tile.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2317 }
2318 else
2319 {
2320 jwin_alert("ZCOMBO File: Success!","Loaded the source combos to your combo pages!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2321 saved=false;
2322 }
2323 }
2324
2325 pack_fclose(f);
2326 }
2327 }
2328 }
2329
2330
2331 static DIALOG read_combopack_dlg[] =
2332 {
2333 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2334
2335
2336 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load Combos (Specific Dest)", NULL, NULL },
2337 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2338 //for future tabs
2339 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2340 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2341 //4
2342 { jwin_text_proc, 10, 24, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2343 { jwin_edit_proc, 55, 22, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2344 //6
2345 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2346 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2347 //8
2348 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2349 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2350 //10
2351 { jwin_check_proc, 10, 58, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2352 //11
2353 { jwin_text_proc, 10, 42, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Skip:", NULL, NULL },
2354 //12
2355 { jwin_edit_proc, 55, 40, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2356
2357 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2358 };
2359
2360
2361
2362 void writesomecombos_to(const char *prompt,int32_t initialval)
2363 {
2364
2365 char firsttile[8];
2366 char skiptile[8];
2367 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2368 sprintf(firsttile,"%d",0);
2369 //int32_t ret;
2370
2371
2372
2373 read_combopack_dlg[0].dp2 = get_zc_font(font_lfont);
2374
2375 sprintf(skiptile,"%d",0);
2376 //sprintf(tilecount,"%d",1);
2377
2378 read_combopack_dlg[5].dp = firsttile;
2379
2380 byte nooverwrite = 0;
2381 int32_t skipover = 0;
2382
2383 sprintf(skiptile,"%d",0);
2384 //sprintf(tilecount,"%d",1);
2385
2386 read_combopack_dlg[12].dp = skiptile;
2387
2388 large_dialog(read_combopack_dlg);
2389
2390 int32_t ret = do_zqdialog(read_combopack_dlg,-1);
2391 jwin_center_dialog(read_combopack_dlg);
2392
2393 if(ret == 8)
2394 {
2395 if (read_combopack_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2396
2397 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2398 skipover = vbound(atoi(skiptile), 0, (MAXCOMBOS-1));
2399 al_trace("skipover is: %d\n", skipover);
2400 //skipover = vbound(skipover, 0, (MAXCOMBOS-1-skipover));
2401 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2402 if(prompt_for_existing_file_compat("Load ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2403 {
2404 char name[256];
2405 extract_name(temppath,name,FILENAMEALL);
2406 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2407 if(f)
2408 {
2409
2410 if (!readcombofile_to_location(f,first_tile_id,nooverwrite, skipover))
2411 {
2412 al_trace("Could not read from .zcombo packfile %s\n", name);
2413 jwin_alert("ZCOMBO File: Error","Could not load the specified combos.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2414 }
2415 else
2416 {
2417 jwin_alert("ZCOMBO File: Success!","Loaded the source combos to your combo pages!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2418 saved=false;
2419 }
2420 pack_fclose(f);
2421 }
2422
2423 }
2424 }
2425 }
2426
2427
2428
2429 static DIALOG save_dmaps_dlg[] =
2430 {
2431 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2432
2433
2434 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save DMaps (.zdmap)", NULL, NULL },
2435 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2436 //for future tabs
2437 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2438 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2439 //4
2440 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2441 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2442 //6
2443 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Last", NULL, NULL },
2444 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2445 //8
2446 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2447 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2448 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2449 };
2450
2451
2452 void savesomedmaps(const char *prompt,int32_t initialval)
2453 {
2454
2455 char firstdmap[8], lastdmap[8];
2456 int32_t first_dmap_id = 0; int32_t last_dmap_id = 0;
2457 sprintf(firstdmap,"%d",0);
2458 sprintf(lastdmap,"%d",1);
2459 //int32_t ret;
2460
2461
2462
2463 save_dmaps_dlg[0].dp2 = get_zc_font(font_lfont);
2464
2465 sprintf(firstdmap,"%d",0);
2466 sprintf(lastdmap,"%d",0);
2467
2468 save_dmaps_dlg[5].dp = firstdmap;
2469 save_dmaps_dlg[7].dp = lastdmap;
2470
2471 large_dialog(save_dmaps_dlg);
2472
2473 int32_t ret = do_zqdialog(save_dmaps_dlg,-1);
2474 jwin_center_dialog(save_dmaps_dlg);
2475
2476 if(ret == 8)
2477 {
2478 first_dmap_id = vbound(atoi(firstdmap), 0, MAXDMAPS-1);
2479 last_dmap_id = vbound(atoi(lastdmap), 0, MAXDMAPS-1);
2480
2481 if ( last_dmap_id < first_dmap_id )
2482 {
2483 int32_t swap = last_dmap_id;
2484 last_dmap_id = first_dmap_id;
2485 first_dmap_id = swap;
2486 }
2487 if(!prompt_for_new_file_compat("Export DMaps (.zdmap)","zdmap",NULL,datapath,false))
2488
2489
2490 saved=false;
2491
2492 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2493 if(f)
2494 {
2495 if(!writesomedmaps(f,first_dmap_id,last_dmap_id,MAXDMAPS))
2496 {
2497 char buf[PATH_MAX+20],name[PATH_MAX];
2498 extract_name(temppath,name,FILENAMEALL);
2499 sprintf(buf,"Unable to load %s",name);
2500 jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2501 }
2502 else
2503 {
2504 char name[PATH_MAX];
2505 extract_name(temppath,name,FILENAMEALL);
2506 char tmpbuf[PATH_MAX+20]={0};
2507 sprintf(tmpbuf,"Saved %s",name);
2508 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2509 }
2510 }
2511 pack_fclose(f);
2512 }
2513 }
2514
2515 static DIALOG save_comboaliasfiles_dlg[] =
2516 {
2517 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2518
2519
2520 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Combo Alias Pack", NULL, NULL },
2521 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2522 //for future tabs
2523 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2524 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2525 //4
2526 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2527 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2528 //6
2529 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2530 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2531 //8
2532 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2533 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2534 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2535 };
2536
2537
2538 void savesomecomboaliases(const char *prompt,int32_t initialval)
2539 {
2540
2541 char firsttile[8], tilecount[8];
2542 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2543 sprintf(firsttile,"%d",0);
2544 sprintf(tilecount,"%d",1);
2545 //int32_t ret;
2546
2547
2548
2549 save_comboaliasfiles_dlg[0].dp2 = get_zc_font(font_lfont);
2550
2551 sprintf(firsttile,"%d",0);
2552 sprintf(tilecount,"%d",1);
2553
2554 save_comboaliasfiles_dlg[5].dp = firsttile;
2555 save_comboaliasfiles_dlg[7].dp = tilecount;
2556
2557 large_dialog(save_comboaliasfiles_dlg);
2558
2559 int32_t ret = do_zqdialog(save_comboaliasfiles_dlg,-1);
2560 jwin_center_dialog(save_comboaliasfiles_dlg);
2561
2562 if(ret == 8)
2563 {
2564 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOALIASES-1));
2565 the_tile_count = vbound(atoi(tilecount), 1, (MAXCOMBOALIASES-1)-first_tile_id);
2566 if(prompt_for_new_file_compat("Save ZALIAS(.zalias)", "zalias", NULL,datapath,false))
2567 {
2568 char name[PATH_MAX];
2569 extract_name(temppath,name,FILENAMEALL);
2570 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2571 if(f)
2572 {
2573 writecomboaliasfile(f,first_tile_id,the_tile_count);
2574 pack_fclose(f);
2575 char tmpbuf[PATH_MAX+20]={0};
2576 sprintf(tmpbuf,"Saved %s",name);
2577 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2578 }
2579 }
2580 }
2581 }
2582
2583
2584 static DIALOG read_comboaliaspack_dlg[] =
2585 {
2586 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2587
2588
2589 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load Combo Pack To:", NULL, NULL },
2590 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2591 //for future tabs
2592 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2593 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2594 //4
2595 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2596 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2597 //6
2598 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2599 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2600 //8
2601 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2602 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2603 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2604 };
2605
2606
2607 void writesomecomboaliases_to(const char *prompt,int32_t initialval)
2608 {
2609
2610 char firsttile[8];;
2611 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2612 sprintf(firsttile,"%d",0);
2613 //int32_t ret;
2614
2615
2616
2617 read_comboaliaspack_dlg[0].dp2 = get_zc_font(font_lfont);
2618
2619 sprintf(firsttile,"%d",0);
2620 //sprintf(tilecount,"%d",1);
2621
2622 read_comboaliaspack_dlg[5].dp = firsttile;
2623
2624 large_dialog(read_comboaliaspack_dlg);
2625
2626 int32_t ret = do_zqdialog(read_comboaliaspack_dlg,-1);
2627 jwin_center_dialog(read_comboaliaspack_dlg);
2628
2629 if(ret == 8)
2630 {
2631 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOALIASES-1));
2632 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2633 if(prompt_for_existing_file_compat("Load ZALIAS(.zalias)", "zalias", NULL,datapath,false))
2634 {
2635 char name[256];
2636 extract_name(temppath,name,FILENAMEALL);
2637 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2638 if(f)
2639 {
2640
2641 if (!readcomboaliasfile_to_location(f,first_tile_id))
2642 {
2643 al_trace("Could not read from .zcombo packfile %s\n", name);
2644 jwin_alert("ZALIAS File: Error","Could not load the specified combo aliases.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2645 }
2646 else
2647 {
2648 jwin_alert("ZALIAS File: Success!","Loaded the source combos to your combo alias table!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2649 saved=false;
2650 }
2651 pack_fclose(f);
2652 }
2653 }
2654 }
2655 }
2656
2657
2658
2659
2660 //Doorsets
2661
2662 static DIALOG save_doorset_dlg[] =
2663 {
2664 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2665 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Doorset", NULL, NULL },
2666 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2667 //for future tabs
2668 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2669 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2670 //4
2671 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2672 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2673 //6
2674 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2675 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2676 //8
2677 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2678 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2679 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2680 };
2681
2682
2683 void do_exportdoorset(const char *prompt,int32_t initialval)
2684 {
2685 char firstdoor[8], doorct[8];
2686 int32_t first_doorset_id = 0; int32_t the_doorset_count = 1;
2687 sprintf(firstdoor,"%d",0);
2688 sprintf(doorct,"%d",1);
2689 //int32_t ret;
2690 save_doorset_dlg[0].dp2 = get_zc_font(font_lfont);
2691
2692 sprintf(firstdoor,"%d",0);
2693 sprintf(doorct,"%d",1);
2694
2695 save_doorset_dlg[5].dp = firstdoor;
2696 save_doorset_dlg[7].dp = doorct;
2697
2698 large_dialog(save_doorset_dlg);
2699
2700 int32_t ret = do_zqdialog(save_doorset_dlg,-1);
2701 jwin_center_dialog(save_doorset_dlg);
2702
2703 if(ret == 8) //OK
2704 {
2705 /* sanity bounds
2706 first_doorset_id = vbound(atoi(firstdoor), 0, (MAXCOMBOS-1));
2707 the_doorset_count = vbound(atoi(doorct), 1, (MAXCOMBOS-1)-first_doorset_id);
2708 */
2709 if(prompt_for_new_file_compat("Save ZDOORS(.zdoors)", "zdoors", NULL,datapath,false))
2710 {
2711 char name[256];
2712 extract_name(temppath,name,FILENAMEALL);
2713 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2714 if(f)
2715 {
2716 writezdoorsets(f,first_doorset_id,the_doorset_count);
2717 pack_fclose(f);
2718 char tmpbuf[512]={0};
2719 sprintf(tmpbuf,"Saved %s",name);
2720 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2721 }
2722 }
2723 }
2724 }
2725
2726 static DIALOG load_doorset_dlg[] =
2727 {
2728 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2729 { jwin_win_proc, 0, 0, 120, 124, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Door Set (Range)", NULL, NULL },
2730 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2731 //for future tabs
2732 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2733 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2734 //4
2735 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First:", NULL, NULL },
2736 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2737 //6
2738 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2739 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2740 //8
2741 { jwin_button_proc, 15, 92, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2742 { jwin_button_proc, 69, 92, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2743 //10
2744 { jwin_text_proc, 10, 64, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Dest", NULL, NULL },
2745 { jwin_edit_proc, 55, 63, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2746 //8
2747
2748 // { jwin_check_proc, 10, 46, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2749
2750 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2751 };
2752
2753 void do_importdoorset(const char *prompt,int32_t initialval)
2754 {
2755
2756 char firstdoor[8], doorct[8], destid[8];
2757 int32_t first_doorset_id = 0; int32_t the_doorset_count = 1;
2758 int32_t the_dest_id = 0;
2759 sprintf(firstdoor,"%d",0);
2760 sprintf(doorct,"%d",1);
2761 sprintf(destid,"%d",0);
2762 //int32_t ret;
2763
2764 save_doorset_dlg[0].dp2 = get_zc_font(font_lfont);
2765
2766 load_doorset_dlg[5].dp = firstdoor;
2767 load_doorset_dlg[7].dp = doorct;
2768 load_doorset_dlg[11].dp = destid;
2769
2770 byte nooverwrite = 0;
2771
2772 large_dialog(load_doorset_dlg);
2773
2774 int32_t ret = do_zqdialog(load_doorset_dlg,-1);
2775 jwin_center_dialog(load_doorset_dlg);
2776
2777 if(ret == 8) //OK
2778 {
2779 //if (load_doorset_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2780
2781 //sanity bound
2782 first_doorset_id = vbound(atoi(firstdoor), 0, door_combo_set_count);
2783 the_doorset_count = vbound(atoi(doorct), 1, door_combo_set_count);
2784 the_dest_id = vbound(atoi(destid), 0, door_combo_set_count);
2785 if(prompt_for_existing_file_compat("Load ZDOORS(.zdoors)", "zdoors", NULL,datapath,false))
2786 {
2787 char name[256];
2788 extract_name(temppath,name,FILENAMEALL);
2789 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2790 if(f)
2791 {
2792 int32_t ret = readzdoorsets(f,first_doorset_id,the_doorset_count, the_dest_id);
2793
2794 if (!ret)
2795 {
2796 al_trace("Could not read from .zdoors packfile %s\n", name);
2797 jwin_alert("ZDOORS File: Error","Could not load the specified doorsets.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2798 }
2799 else if ( ret == 1 )
2800 {
2801 jwin_alert("ZDOORS File: Success!","Loaded the source doorsets!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2802 saved=false;
2803 }
2804 else if ( ret == 2 )
2805 {
2806 jwin_alert("ZDOORS File: Issue:","Targets exceed doorset count!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2807 saved=false;
2808 }
2809 pack_fclose(f);
2810 }
2811 }
2812 }
2813 }
2814
2815 int32_t gettilepagenumber(const char *prompt, int32_t initialval)
2816 {
2817 char buf[20];
2818 sprintf(buf,"%d",initialval);
2819 getnum_dlg[0].dp=(void *)prompt;
2820 getnum_dlg[0].dp2=get_zc_font(font_lfont);
2821 getnum_dlg[2].dp=buf;
2822
2823 large_dialog(getnum_dlg);
2824
2825 int32_t ret = do_zqdialog(getnum_dlg,2);
2826
2827 if(ret==3)
2828 return atoi(buf);
2829
2830 return -1;
2831 }
2832
2833 int32_t gethexnumber(const char *prompt,int32_t initialval)
2834 {
2835 cancelgetnum=true;
2836 char buf[20];
2837 sprintf(buf,"%X",initialval);
2838 getnum_dlg[0].dp=(void *)prompt;
2839 getnum_dlg[0].dp2=get_zc_font(font_lfont);
2840 getnum_dlg[2].dp=(void *)buf;
2841
2842 large_dialog(getnum_dlg);
2843
2844 int32_t ret=do_zqdialog(getnum_dlg,2);
2845
2846 if(ret!=0&&ret!=4)
2847 {
2848 cancelgetnum=false;
2849 }
2850
2851 if(ret==3)
2852 return zc_xtoi(buf);
2853
2854 return initialval;
2855 }
2856
2857 void update_combo_cycling()
2858 {
2859 Map.update_combo_cycling();
2860 }
2861
2862 void update_freeform_combos()
2863 {
2864 Map.update_freeform_combos();
2865 }
2866
2867 bool layers_valid(mapscr *tempscr)
2868 {
2869 for(int32_t i=0; i<6; i++)
2870 {
2871 if(tempscr->layermap[i]>map_count)
2872 {
2873 return false;
2874 }
2875 }
2876
2877 return true;
2878 }
2879
2880 void fix_layers(mapscr *tempscr, bool showwarning)
2881 {
2882 char buf[80]="layers have been changed: ";
2883
2884 for(int32_t i=0; i<6; i++)
2885 {
2886 if(tempscr->layermap[i]>map_count)
2887 {
2888 strcat(buf, "%d ");
2889 sprintf(buf, buf, i+1);
2890 tempscr->layermap[i]=0;
2891 }
2892 }
2893
2894 if(showwarning)
2895 {
2896 jwin_alert("Invalid layers detected",
2897 "One or more layers on this screen used",
2898 "maps that do not exist. The settings of these",
2899 buf, "O&K", NULL, 'o', 0, get_zc_font(font_lfont));
2900 }
2901 }
2902
2903 extern const char *colorlist(int32_t index, int32_t *list_size);
2904
2905 static char autobackup_str_buf[32];
2906 const char *autobackuplist(int32_t index, int32_t *list_size)
2907 {
2908 if(index>=0)
2909 {
2910 bound(index,0,10);
2911
2912 if(index==0)
2913 {
2914 sprintf(autobackup_str_buf,"Disabled");
2915 }
2916 else
2917 {
2918 sprintf(autobackup_str_buf,"%2d",index);
2919 }
2920
2921 return autobackup_str_buf;
2922 }
2923
2924 *list_size=11;
2925 return NULL;
2926 }
2927
2928 static char autosave_str_buf[32];
2929 const char *autosavelist(int32_t index, int32_t *list_size)
2930 {
2931 if(index>=0)
2932 {
2933 bound(index,0,10);
2934
2935 if(index==0)
2936 {
2937 sprintf(autosave_str_buf,"Disabled");
2938 }
2939 else
2940 {
2941 sprintf(autosave_str_buf,"%2d Minute%c",index,index>1?'s':0);
2942 }
2943
2944 return autosave_str_buf;
2945 }
2946
2947 *list_size=11;
2948 return NULL;
2949 }
2950
2951 const char *autosavelist2(int32_t index, int32_t *list_size)
2952 {
2953 if(index>=0)
2954 {
2955 bound(index,0,9);
2956 sprintf(autosave_str_buf,"%2d",index+1);
2957 return autosave_str_buf;
2958 }
2959
2960 *list_size=10;
2961 return NULL;
2962 }
2963
2964
2965 static int32_t options_1_list[] =
2966 {
2967 // dialog control number
2968 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, -1
2969 };
2970
2971 static int32_t options_2_list[] =
2972 {
2973 // dialog control number
2974 50, 51, -1
2975 };
2976
2977 static int32_t options_3_list[] =
2978 {
2979 // dialog control number
2980 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, -1
2981 };
2982 static int32_t options_4_list[] =
2983 {
2984 57, 58, 59, 60,
2985 -1
2986 };
2987
2988 static TABPANEL options_tabs[] =
2989 {
2990 // (text)
2991 { (char *)" 1 ", D_SELECTED, options_1_list, 0, NULL },
2992 { (char *)" 2 ", 0, options_2_list, 0, NULL },
2993 { (char *)" 3 ", 0, options_3_list, 0, NULL },
2994 { (char *)" 4 ", 0, options_4_list, 0, NULL },
2995 { NULL, 0, NULL, 0, NULL }
2996 };
2997
2998 12 static ListData autobackup_list(autobackuplist, &font);
2999 12 static ListData autosave_list(autosavelist, &font);
3000 12 static ListData autosave_list2(autosavelist2, &font);
3001 12 static ListData color_list(colorlist, &font);
3002 12 static ListData snapshotformat_list(snapshotformatlist, &font);
3003
3004 const char *dm_names[dm_max]=
3005 {
3006 "Normal",
3007 "Relational", // Removed.
3008 "Dungeon", // Removed.
3009 "Alias",
3010 "Pool",
3011 "Auto"
3012 };
3013
3014 void fix_drawing_mode_menu()
3015 {
3016 drawing_mode_menu.select_only_uid(draw_mode);
3017 }
3018
3019 int32_t onDrawingMode()
3020 {
3021 draw_mode=(draw_mode+1)%dm_max;
3022 int dm_relational = 1;
3023 if ((int)draw_mode == dm_relational)
3024 draw_mode += 2;
3025 fix_drawing_mode_menu();
3026 restore_mouse();
3027 return D_O_K;
3028 }
3029
3030 int32_t onDrawingModeNormal()
3031 {
3032 draw_mode=dm_normal;
3033 fix_drawing_mode_menu();
3034 restore_mouse();
3035 return D_O_K;
3036 }
3037
3038 int32_t onDrawingModeAlias()
3039 {
3040 if(draw_mode==dm_alias)
3041 {
3042 return onDrawingModeNormal();
3043 }
3044
3045 draw_mode=dm_alias;
3046 alias_cset_mod=0;
3047 fix_drawing_mode_menu();
3048 restore_mouse();
3049 return D_O_K;
3050 }
3051
3052 int32_t onDrawingModePool()
3053 {
3054 if(draw_mode==dm_cpool)
3055 {
3056 return onDrawingModeNormal();
3057 }
3058
3059 draw_mode=dm_cpool;
3060 fix_drawing_mode_menu();
3061 restore_mouse();
3062 return D_O_K;
3063 }
3064
3065 int32_t onDrawingModeAuto()
3066 {
3067 if (draw_mode == dm_auto)
3068 {
3069 return onDrawingModeNormal();
3070 }
3071
3072 draw_mode = dm_auto;
3073 fix_drawing_mode_menu();
3074 restore_mouse();
3075 return D_O_K;
3076 }
3077
3078 int32_t onReTemplate()
3079 {
3080 if(jwin_alert("Confirm Overwrite","Apply NES Dungeon template to","all screens on this map?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
3081 {
3082 Map.TemplateAll();
3083 refresh(rALL);
3084 }
3085
3086 return D_O_K;
3087 }
3088
3089 int32_t onUndo()
3090 {
3091 Map.UndoCommand();
3092 refresh(rALL);
3093 return D_O_K;
3094 }
3095
3096 int32_t onRedo()
3097 {
3098 Map.RedoCommand();
3099 refresh(rALL);
3100 return D_O_K;
3101 }
3102
3103 int32_t onCopy()
3104 {
3105 if(prv_mode)
3106 {
3107 Map.set_prvcmb(Map.get_prvcmb()==0?1:0);
3108 return D_O_K;
3109 }
3110
3111 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3112 Map.Copy(screen);
3113 return D_O_K;
3114 }
3115
3116 int32_t onPaste()
3117 {
3118 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
3119 {
3120 if(CHECK_CTRL_CMD)
3121 return onPasteAllToAll();
3122 else return onPasteAll();
3123 }
3124 else if(CHECK_CTRL_CMD)
3125 return onPasteToAll();
3126 else
3127 {
3128 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3129 Map.DoPasteScreenCommand(PasteCommandType::ScreenPartial, screen);
3130 }
3131 return D_O_K;
3132 }
3133
3134 int32_t onPasteAll()
3135 {
3136 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3137 Map.DoPasteScreenCommand(PasteCommandType::ScreenAll, screen);
3138 return D_O_K;
3139 }
3140
3141 int32_t onPasteToAll()
3142 {
3143 if(confirmBox("You are about to paste to all screens on the current map."))
3144 {
3145 Map.DoPasteScreenCommand(PasteCommandType::ScreenPartialToEveryScreen);
3146 }
3147 return D_O_K;
3148 }
3149
3150 int32_t onPasteAllToAll()
3151 {
3152 if(confirmBox("You are about to paste to all screens on the current map."))
3153 {
3154 Map.DoPasteScreenCommand(PasteCommandType::ScreenAllToEveryScreen);
3155 }
3156 return D_O_K;
3157 }
3158
3159 int32_t onPasteUnderCombo()
3160 {
3161 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3162 Map.DoPasteScreenCommand(PasteCommandType::ScreenUnderCombo, screen);
3163 return D_O_K;
3164 }
3165
3166 int32_t onPasteSecretCombos()
3167 {
3168 Map.DoPasteScreenCommand(PasteCommandType::ScreenSecretCombos);
3169 return D_O_K;
3170 }
3171
3172 int32_t onPasteFFCombos()
3173 {
3174 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3175 Map.DoPasteScreenCommand(PasteCommandType::ScreenFFCombos, screen);
3176 return D_O_K;
3177 }
3178
3179 int32_t onPasteWarps()
3180 {
3181 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3182 Map.DoPasteScreenCommand(PasteCommandType::ScreenWarps, screen);
3183 return D_O_K;
3184 }
3185
3186 int32_t onPasteScreenData()
3187 {
3188 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3189 Map.DoPasteScreenCommand(PasteCommandType::ScreenData, screen);
3190 return D_O_K;
3191 }
3192
3193 int32_t onPasteWarpLocations()
3194 {
3195 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3196 Map.DoPasteScreenCommand(PasteCommandType::ScreenWarpLocations, screen);
3197 return D_O_K;
3198 }
3199
3200 int32_t onPasteDoors()
3201 {
3202 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3203 Map.DoPasteScreenCommand(PasteCommandType::ScreenDoors, screen);
3204 return D_O_K;
3205 }
3206
3207 int32_t onPasteLayers()
3208 {
3209 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3210 Map.DoPasteScreenCommand(PasteCommandType::ScreenLayers, screen);
3211 return D_O_K;
3212 }
3213
3214 int32_t onPastePalette()
3215 {
3216 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3217 Map.DoPasteScreenCommand(PasteCommandType::ScreenPalette, screen);
3218 return D_O_K;
3219 }
3220
3221 int32_t onPasteRoom()
3222 {
3223 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3224 Map.DoPasteScreenCommand(PasteCommandType::ScreenRoom, screen);
3225 return D_O_K;
3226 }
3227
3228 int32_t onPasteGuy()
3229 {
3230 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3231 Map.DoPasteScreenCommand(PasteCommandType::ScreenGuy, screen);
3232 return D_O_K;
3233 }
3234
3235 int32_t onPasteEnemies()
3236 {
3237 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3238 Map.DoPasteScreenCommand(PasteCommandType::ScreenEnemies, screen);
3239 return D_O_K;
3240 }
3241
3242 int32_t onDelete()
3243 {
3244 restore_mouse();
3245
3246 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3247 mapscr* scr = active_visible_screen ? active_visible_screen->scr : Map.CurrScr();
3248 if(!(scr->valid&mVALID) || jwin_alert("Confirm Delete","Delete this screen?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3249 {
3250 Map.DoClearScreenCommand(screen);
3251 }
3252
3253 saved=false;
3254 return D_O_K;
3255 }
3256
3257 int32_t onDeleteMap()
3258 {
3259 if(jwin_alert("Confirm Delete","Clear this entire map?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3260 {
3261 Map.clearmap(false);
3262 refresh(rALL);
3263 saved=false;
3264 }
3265
3266 return D_O_K;
3267 }
3268
3269 int32_t onToggleDarkness()
3270 {
3271 Map.CurrScr()->flags^=4;
3272 refresh(rMAP+rMENU);
3273 saved=false;
3274 return D_O_K;
3275 }
3276
3277 int32_t onIncMap()
3278 {
3279 int32_t m=Map.getCurrMap();
3280 int32_t oldcolor=Map.getcolor();
3281 Map.setCurrMap(m+1>=map_count?0:m+1);
3282 // Map.setCurrScr(Map.getCurrScr()); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3283 Map.setlayertarget(); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3284
3285 int32_t newcolor=Map.getcolor();
3286
3287 if(newcolor!=oldcolor)
3288 {
3289 rebuild_trans_table();
3290 }
3291
3292 refresh(rALL);
3293 return D_O_K;
3294 }
3295
3296 int32_t onDecMap()
3297 {
3298 int32_t m=Map.getCurrMap();
3299 int32_t oldcolor=Map.getcolor();
3300 Map.setCurrMap((m-1<0)?map_count-1:zc_min(m-1,map_count-1));
3301 // Map.setCurrScr(Map.getCurrScr()); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3302 Map.setlayertarget(); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3303
3304 int32_t newcolor=Map.getcolor();
3305
3306 if(newcolor!=oldcolor)
3307 {
3308 rebuild_trans_table();
3309 }
3310
3311 refresh(rALL);
3312 return D_O_K;
3313 }
3314
3315
3316 int32_t onDefault_Pals()
3317 {
3318 if(jwin_alert("Confirm Reset","Reset all palette data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3319 {
3320 saved=false;
3321
3322 if(!init_colordata(true, &header, &QMisc))
3323 {
3324 jwin_alert("Error","Palette reset failed.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
3325 }
3326
3327 refresh_pal();
3328 }
3329
3330 return D_O_K;
3331 }
3332
3333 int32_t onDefault_Combos()
3334 {
3335 if(jwin_alert("Confirm Reset","Reset combo data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3336 {
3337 saved=false;
3338
3339 if(!init_combos(true, &header))
3340 {
3341 jwin_alert("Error","Combo reset failed.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
3342 }
3343
3344 refresh(rALL);
3345 }
3346
3347 return D_O_K;
3348 }
3349
3350 int32_t onDefault_Items()
3351 {
3352 if(jwin_alert("Confirm Reset","Reset all items?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3353 {
3354 saved=false;
3355 reset_items(true, &header);
3356 }
3357
3358 return D_O_K;
3359 }
3360
3361 int32_t onDefault_Weapons()
3362 {
3363 if(jwin_alert("Confirm Reset","Reset weapon/misc. sprite data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3364 {
3365 saved=false;
3366 reset_wpns(true, &header);
3367 }
3368
3369 return D_O_K;
3370 }
3371
3372 int32_t onDefault_Guys()
3373 {
3374 if(jwin_alert("Confirm Reset","Reset all enemy/NPC data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3375 {
3376 saved=false;
3377 reset_guys();
3378 }
3379
3380 return D_O_K;
3381 }
3382
3383
3384 int32_t onDefault_Tiles()
3385 {
3386 if(jwin_alert("Confirm Reset","Reset all tiles?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3387 {
3388 saved=false;
3389
3390 if(!init_tiles(true, &header))
3391 {
3392 jwin_alert("Error","Tile reset failed.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
3393 }
3394
3395 refresh(rALL);
3396 }
3397
3398 return D_O_K;
3399 }
3400
3401 void change_sfx(SAMPLE *sfx1, SAMPLE *sfx2);
3402
3403 int32_t onDefault_SFX()
3404 {
3405 if(jwin_alert("Confirm Reset","Reset all sound effects?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3406 {
3407 saved=false;
3408 SAMPLE *temp_sample;
3409
3410 for(int32_t i=1; i<WAV_COUNT; i++)
3411 {
3412 temp_sample = (SAMPLE *)sfxdata[zc_min(i,Z35)].dat;
3413 change_sfx(&customsfxdata[i], temp_sample);
3414 sprintf(sfx_string[i],"s%03d",i);
3415
3416 if(i<Z35)
3417 strcpy(sfx_string[i], old_sfx_string[i-1]);
3418 set_bit(customsfxflag, i<Z35?1:0, i-1);
3419 }
3420 }
3421
3422 return D_O_K;
3423 }
3424
3425
3426 int32_t onDefault_MapStyles()
3427 {
3428 if(jwin_alert("Confirm Reset","Reset all map styles?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3429 {
3430 saved=false;
3431 reset_mapstyles(true, &QMisc);
3432 }
3433
3434 return D_O_K;
3435 }
3436
3437 int onScrollScreen(int dir, bool warp)
3438 {
3439 Map.scroll(dir,warp);
3440 return D_O_K;
3441 }
3442
3443 int32_t onComboColLeft()
3444 {
3445 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3446 ;
3447 else if((First[current_combolist]>0)&&(draw_mode!=dm_alias))
3448 {
3449 First[current_combolist]-=1;
3450 clear_tooltip();
3451 refresh(rCOMBOS);
3452 }
3453 else if((combo_alistpos[current_comboalist]>0)&&(draw_mode==dm_alias))
3454 {
3455 combo_alistpos[current_comboalist]-=1;
3456 clear_tooltip();
3457 refresh(rCOMBOS);
3458 }
3459
3460 clear_keybuf();
3461 return D_O_K;
3462 }
3463
3464 int32_t onComboColRight()
3465 {
3466 auto& sqr = (draw_mode == dm_alias ? comboaliaslist[current_comboalist] : combolist[current_combolist]);
3467 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3468 ;
3469 else if((First[current_combolist]<(MAXCOMBOS-(sqr.w*sqr.h)))&&(draw_mode!=dm_alias))
3470 {
3471 First[current_combolist]+=1;
3472 clear_tooltip();
3473 refresh(rCOMBOS);
3474 }
3475 else if((combo_alistpos[current_comboalist]<(MAXCOMBOALIASES-(sqr.w*sqr.h)))&&(draw_mode==dm_alias))
3476 {
3477 combo_alistpos[current_comboalist]+=1;
3478 clear_tooltip();
3479 refresh(rCOMBOS);
3480 }
3481
3482 clear_keybuf();
3483 return D_O_K;
3484 }
3485
3486 int32_t onComboColUp()
3487 {
3488 auto& sqr = (draw_mode == dm_alias ? comboaliaslist[current_comboalist] : combolist[current_combolist]);
3489 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3490 ;
3491 else if((First[current_combolist]>0)&&(draw_mode!=dm_alias))
3492 {
3493 First[current_combolist]-=zc_min(First[current_combolist],sqr.w);
3494 clear_tooltip();
3495
3496 refresh(rCOMBOS);
3497 }
3498 else if((combo_alistpos[current_comboalist]>0)&&(draw_mode==dm_alias))
3499 {
3500 combo_alistpos[current_comboalist]-=zc_min(combo_alistpos[current_comboalist],sqr.w);
3501 clear_tooltip();
3502 refresh(rCOMBOS);
3503 }
3504
3505 clear_keybuf();
3506 return D_O_K;
3507 }
3508
3509 int32_t onComboColDown()
3510 {
3511 auto& sqr = (draw_mode == dm_alias ? comboaliaslist[current_comboalist] : combolist[current_combolist]);
3512
3513 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3514 ;
3515 else if((First[current_combolist]<(MAXCOMBOS-(sqr.w*sqr.h)))&&(draw_mode!=dm_alias))
3516 {
3517 First[current_combolist]+=zc_min((MAXCOMBOS-sqr.w)-First[current_combolist],sqr.w);
3518 clear_tooltip();
3519 refresh(rCOMBOS);
3520 }
3521 else if((combo_alistpos[current_comboalist]<(MAXCOMBOALIASES-(comboaliaslist[0].w*comboaliaslist[0].h)))&&(draw_mode==dm_alias))
3522 {
3523 combo_alistpos[current_comboalist]+=zc_min((MAXCOMBOALIASES-sqr.w)-combo_alistpos[current_comboalist],sqr.w);
3524 clear_tooltip();
3525 refresh(rCOMBOS);
3526 }
3527
3528 clear_keybuf();
3529 return D_O_K;
3530 }
3531
3532 void scrollup(int j)
3533 {
3534 switch(draw_mode)
3535 {
3536 case dm_alias:
3537 {
3538 auto& sqr = comboaliaslist[j];
3539 if(combo_alistpos[j]>0)
3540 {
3541 if(CHECK_CTRL_CMD)
3542 {
3543 combo_alistpos[j]=0;
3544 clear_tooltip();
3545 }
3546 else
3547 {
3548 combo_alistpos[j]-=zc_min(combo_alistpos[j],(sqr.w*sqr.h));
3549 clear_tooltip();
3550 }
3551
3552 refresh(rCOMBOS);
3553 }
3554 break;
3555 }
3556 case dm_cpool:
3557 {
3558 auto& sqr = comboaliaslist[j];
3559 if(combo_pool_listpos[j]>0)
3560 {
3561 if(CHECK_CTRL_CMD)
3562 {
3563 combo_pool_listpos[j]=0;
3564 clear_tooltip();
3565 }
3566 else
3567 {
3568 combo_pool_listpos[j]-=zc_min(combo_pool_listpos[j],(sqr.w*sqr.h));
3569 clear_tooltip();
3570 }
3571
3572 refresh(rCOMBOS);
3573 }
3574 break;
3575 }
3576 case dm_auto:
3577 {
3578 auto& sqr = comboaliaslist[j];
3579 if (combo_auto_listpos[j] > 0)
3580 {
3581 if (CHECK_CTRL_CMD)
3582 {
3583 combo_auto_listpos[j] = 0;
3584 clear_tooltip();
3585 }
3586 else
3587 {
3588 combo_auto_listpos[j] -= zc_min(combo_auto_listpos[j], (sqr.w * sqr.h));
3589 clear_tooltip();
3590 }
3591
3592 refresh(rCOMBOS);
3593 }
3594 break;
3595 }
3596 default:
3597 {
3598 auto& sqr = combolist[j];
3599 if(First[j]>0)
3600 {
3601 if(CHECK_CTRL_CMD)
3602 {
3603 First[j]-=zc_min(First[j],256);
3604 clear_tooltip();
3605 }
3606 else
3607 {
3608 First[j]-=zc_min(First[j],(sqr.w*sqr.h));
3609 clear_tooltip();
3610 }
3611
3612 refresh(rCOMBOS);
3613 }
3614 break;
3615 }
3616 }
3617 }
3618 void scrolldown(int j)
3619 {
3620 switch(draw_mode)
3621 {
3622 case dm_alias:
3623 {
3624 auto& sqr = comboaliaslist[j];
3625 if(combo_alistpos[j]<(MAXCOMBOALIASES-(sqr.w*sqr.h)))
3626 {
3627 if(CHECK_CTRL_CMD)
3628 {
3629 combo_alistpos[j]=MAXCOMBOALIASES-(sqr.w*sqr.h);
3630 clear_tooltip();
3631 }
3632 else
3633 {
3634 combo_alistpos[j]=zc_min((MAXCOMBOALIASES-(sqr.w*sqr.h)),combo_alistpos[j]+(sqr.w*sqr.h));
3635 clear_tooltip();
3636 }
3637
3638 refresh(rCOMBOS);
3639 }
3640 break;
3641 }
3642 case dm_cpool:
3643 {
3644 auto& sqr = comboaliaslist[j];
3645 if(combo_pool_listpos[j]<(MAXCOMBOALIASES-(sqr.w*sqr.h)))
3646 {
3647 if(CHECK_CTRL_CMD)
3648 {
3649 combo_pool_listpos[j]=MAXCOMBOALIASES-(sqr.w*sqr.h);
3650 clear_tooltip();
3651 }
3652 else
3653 {
3654 combo_pool_listpos[j]=zc_min((MAXCOMBOALIASES-(sqr.w*sqr.h)),combo_pool_listpos[j]+(sqr.w*sqr.h));
3655 clear_tooltip();
3656 }
3657
3658 refresh(rCOMBOS);
3659 }
3660 break;
3661 }
3662 case dm_auto:
3663 {
3664 auto& sqr = comboaliaslist[j];
3665 if (combo_auto_listpos[j] < (MAXCOMBOALIASES - (sqr.w * sqr.h)))
3666 {
3667 if (CHECK_CTRL_CMD)
3668 {
3669 combo_auto_listpos[j] = MAXCOMBOALIASES - (sqr.w * sqr.h);
3670 clear_tooltip();
3671 }
3672 else
3673 {
3674 combo_auto_listpos[j] = zc_min((MAXCOMBOALIASES - (sqr.w * sqr.h)), combo_pool_listpos[j] + (sqr.w * sqr.h));
3675 clear_tooltip();
3676 }
3677
3678 refresh(rCOMBOS);
3679 }
3680 break;
3681 }
3682 default:
3683 {
3684 auto& sqr = combolist[j];
3685 if(First[j]<(MAXCOMBOS-(sqr.w*sqr.h)))
3686 {
3687 if(CHECK_CTRL_CMD)
3688 {
3689 First[j]=zc_min((MAXCOMBOS-sqr.w*sqr.h),First[j]+256);
3690 clear_tooltip();
3691 }
3692 else
3693 {
3694 First[j]=zc_min((MAXCOMBOS-(sqr.w*sqr.h)),First[j]+(sqr.w*sqr.h));
3695 clear_tooltip();
3696 }
3697
3698 refresh(rCOMBOS);
3699 }
3700 break;
3701 }
3702 }
3703 }
3704
3705 int32_t onPgUp()
3706 {
3707 switch(draw_mode)
3708 {
3709 case dm_alias:
3710 scrollup(current_comboalist);
3711 break;
3712 case dm_cpool:
3713 scrollup(current_cpoollist);
3714 break;
3715 case dm_auto:
3716 scrollup(current_cautolist);
3717 break;
3718 default:
3719 scrollup(current_combolist);
3720 break;
3721 }
3722 return D_O_K;
3723 }
3724
3725 int32_t onPgDn()
3726 {
3727 switch(draw_mode)
3728 {
3729 case dm_alias:
3730 scrolldown(current_comboalist);
3731 break;
3732 case dm_cpool:
3733 scrolldown(current_cpoollist);
3734 break;
3735 case dm_auto:
3736 scrolldown(current_cautolist);
3737 break;
3738 default:
3739 scrolldown(current_combolist);
3740 break;
3741 }
3742 return D_O_K;
3743 }
3744
3745 int32_t onIncreaseCSet()
3746 {
3747 if(draw_mode!=dm_alias)
3748 {
3749 CSet=wrap(CSet+1,0,13);
3750 refresh(rCOMBOS+rMENU+rCOMBO);
3751 }
3752 else
3753 {
3754 alias_cset_mod=wrap(alias_cset_mod+1,0,13);
3755 }
3756 return D_O_K;
3757 }
3758
3759 int32_t onDecreaseCSet()
3760 {
3761 if(draw_mode!=dm_alias)
3762 {
3763 CSet=wrap(CSet-1,0,13);
3764 refresh(rCOMBOS+rMENU+rCOMBO);
3765 }
3766 else
3767 {
3768 alias_cset_mod=wrap(alias_cset_mod-1,0,13);
3769 }
3770 return D_O_K;
3771 }
3772
3773 int32_t onGotoPage()
3774 {
3775 if (draw_mode==dm_alias)
3776 {
3777 static const int PER_PAGE = 260;
3778 if(optional<int> v = call_get_num("Scroll to Alias Page", 0, MAXCOMBOALIASES/PER_PAGE-1, 0))
3779 combo_alistpos[current_comboalist] = *v*PER_PAGE;
3780 }
3781 else if (draw_mode==dm_cpool)
3782 {
3783 static const int PER_PAGE = 260;
3784 if(optional<int> v = call_get_num("Scroll to Combo Pool Page", 0, MAXCOMBOPOOLS/PER_PAGE-1, 0))
3785 combo_pool_listpos[current_cpoollist] = *v*PER_PAGE;
3786 }
3787 else if (draw_mode == dm_auto)
3788 {
3789 static const int PER_PAGE = 260;
3790 if(optional<int> v = call_get_num("Scroll to Auto Combo Page", 0, MAXAUTOCOMBOS/PER_PAGE-1, 0))
3791 combo_auto_listpos[current_cautolist] = *v*PER_PAGE;
3792 }
3793 else
3794 {
3795 static const int PER_PAGE = 256;
3796 if(optional<int> v = call_get_num("Scroll to Combo Page", 0, MAXCOMBOS/PER_PAGE-1, 0))
3797 First[current_combolist] = *v*PER_PAGE;
3798 }
3799
3800 return D_O_K;
3801 }
3802
3803 static char track_number_str_buf[MIDI_TRACK_BUFFER_SIZE] = {0};
3804 const char *tracknumlist(int32_t index, int32_t *list_size)
3805 {
3806 //memset(track_number_str_buf,0,50);
3807 if(index>=0)
3808 {
3809 bound(index,0,255);
3810 std::string name = zcmusic_get_track_name(zcmusic, index);
3811 sprintf(track_number_str_buf,"%02d %s",index+1, name.c_str());
3812 return track_number_str_buf;
3813 }
3814
3815 *list_size=zcmusic_get_tracks(zcmusic);
3816 return NULL;
3817 }
3818
3819 12 static ListData tracknum_list(tracknumlist, &font);
3820
3821 static DIALOG change_track_dlg[] =
3822 {
3823 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
3824 12 { jwin_win_proc, 60-12, 40, 200-16, 72, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select Track", NULL, NULL },
3825 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
3826 12 { jwin_droplist_proc, 72-12, 60+4, 161, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &tracknum_list, NULL, NULL },
3827 12 { jwin_button_proc, 70, 87, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
3828 12 { jwin_button_proc, 150, 87, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
3829 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
3830 };
3831 // return list_dlg[2].d1;
3832
3833 int32_t changeTrack()
3834 {
3835 restore_mouse();
3836 change_track_dlg[0].dp2=get_zc_font(font_lfont);
3837 change_track_dlg[2].d1=gme_track;
3838
3839 large_dialog(change_track_dlg);
3840
3841 if(do_zqdialog(change_track_dlg,2)==3)
3842 {
3843 gme_track=change_track_dlg[2].d1;
3844 zcmusic_change_track(zcmusic, gme_track);
3845 }
3846
3847 return D_O_K;
3848 }
3849
3850 void set_media_tunes()
3851 {
3852 media_menu.select_uid(MENUID_MEDIA_TUNES, true);
3853 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, false);
3854 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
3855 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
3856
3857 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
3858 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
3859 }
3860
3861 int32_t playMusic()
3862 {
3863 char *ext;
3864 bool ismidi=false;
3865 char allmusic_types[256];
3866 sprintf(allmusic_types, "%s;mid", zcmusic_types);
3867
3868 if(prompt_for_existing_file_compat("Load Music",(char*)allmusic_types,NULL,midipath,false))
3869 {
3870 strcpy(midipath,temppath);
3871
3872 ext=get_extension(midipath);
3873
3874 if(
3875 (stricmp(ext,"ogg")==0)||
3876 (stricmp(ext,"mp3")==0)||
3877 (stricmp(ext,"it")==0)||
3878 (stricmp(ext,"xm")==0)||
3879 (stricmp(ext,"s3m")==0)||
3880 (stricmp(ext,"mod")==0)||
3881 (stricmp(ext,"spc")==0)||
3882 (stricmp(ext,"gym")==0)||
3883 (stricmp(ext,"nsf")==0)||
3884 (stricmp(ext,"gbs")==0)||
3885 (stricmp(ext,"vgm")==0)
3886 )
3887 {
3888 ismidi=false;
3889 }
3890 else if((stricmp(ext,"mid")==0))
3891 {
3892 ismidi=true;
3893 }
3894 else
3895 {
3896 return D_O_K;
3897 }
3898
3899 zc_stop_midi();
3900
3901 if(zcmusic != NULL)
3902 {
3903 zcmusic_stop(zcmusic);
3904 zcmusic_unload_file(zcmusic);
3905 zcmusic = NULL;
3906 zcmixer->newtrack = NULL;
3907 }
3908
3909 if(ismidi)
3910 {
3911 packfile_password("");
3912 if((song=load_midi(midipath))!=NULL)
3913 {
3914 if(zc_play_midi(song,true)==0)
3915 {
3916 media_menu.select_uid(MENUID_MEDIA_TUNES, false);
3917 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, true);
3918 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
3919 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
3920
3921 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
3922 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
3923 }
3924 }
3925 }
3926 else
3927 {
3928 gme_track=0;
3929 zcmusic = (ZCMUSIC*)zcmusic_load_file(midipath);
3930
3931 if(zcmusic!=NULL)
3932 {
3933 media_menu.select_uid(MENUID_MEDIA_TUNES, false);
3934 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, true);
3935 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
3936 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
3937
3938 bool distrack = zcmusic_get_tracks(zcmusic)<2;
3939 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, distrack);
3940 disable_hotkey(ZQKEY_CHANGE_TRACK, distrack);
3941
3942 zcmusic_play(zcmusic, midi_volume);
3943 }
3944 }
3945 }
3946
3947 return D_O_K;
3948 }
3949
3950 int32_t playZCForever()
3951 {
3952 stopMusic();
3953
3954 zcmusic = zcmusic_load_file("assets/zc/ZC_Forever_HD.mp3");
3955 if (zcmusic)
3956 {
3957 zcmusic_play(zcmusic, midi_volume);
3958 set_media_tunes();
3959 }
3960 return D_O_K;
3961 }
3962
3963 // It took awhile to get these values right, so no meddlin'!
3964 int32_t playTune1()
3965 {
3966 return playTune(0);
3967 }
3968 int32_t playTune2()
3969 {
3970 return playTune(81);
3971 }
3972 int32_t playTune3()
3973 {
3974 return playTune(233);
3975 }
3976 int32_t playTune4()
3977 {
3978 return playTune(553);
3979 }
3980 int32_t playTune5()
3981 {
3982 return playTune(814);
3983 }
3984 int32_t playTune6()
3985 {
3986 return playTune(985);
3987 }
3988 int32_t playTune7()
3989 {
3990 return playTune(1153);
3991 }
3992 int32_t playTune8()
3993 {
3994 return playTune(1333);
3995 }
3996 int32_t playTune9()
3997 {
3998 return playTune(1556);
3999 }
4000 int32_t playTune10()
4001 {
4002 return playTune(1801);
4003 }
4004 int32_t playTune11()
4005 {
4006 return playTune(2069);
4007 }
4008 int32_t playTune12()
4009 {
4010 return playTune(2189);
4011 }
4012 int32_t playTune13()
4013 {
4014 return playTune(2569);
4015 }
4016 int32_t playTune14()
4017 {
4018 return playTune(2753);
4019 }
4020 int32_t playTune15()
4021 {
4022 return playTune(2856);
4023 }
4024 int32_t playTune16()
4025 {
4026 return playTune(3042);
4027 }
4028 int32_t playTune17()
4029 {
4030 return playTune(3125);
4031 }
4032 int32_t playTune18()
4033 {
4034 return playTune(3217);
4035 }
4036 int32_t playTune19()
4037 {
4038 return playTune(3296);
4039 }
4040
4041 int32_t playTune(int32_t pos)
4042 {
4043 zc_stop_midi();
4044
4045 if(zcmusic != NULL)
4046 {
4047 zcmusic_stop(zcmusic);
4048 zcmusic_unload_file(zcmusic);
4049 zcmusic = NULL;
4050 zcmixer->newtrack = NULL;
4051 }
4052
4053 if(zc_play_midi(asset_tunes_midi,true)==0)
4054 {
4055 zc_midi_seek(pos);
4056 set_media_tunes();
4057 }
4058
4059 return D_O_K;
4060 }
4061
4062 int32_t stopMusic()
4063 {
4064 zc_stop_midi();
4065
4066 if(zcmusic != NULL)
4067 {
4068 zcmusic_stop(zcmusic);
4069 zcmusic_unload_file(zcmusic);
4070 zcmusic = NULL;
4071 zcmixer->newtrack = NULL;
4072 }
4073
4074 media_menu.select_uid(MENUID_MEDIA_TUNES, false);
4075 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, false);
4076 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
4077 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
4078
4079 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
4080 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
4081 return D_O_K;
4082 }
4083
4084 static int32_t gamemisc1_list[] =
4085 {
4086 5,6,7,8,
4087 9,10,11,12,
4088
4089 37,38,39,40,
4090 41,42,43,44,
4091
4092 71,72,73,74,
4093 75,76,77,78,
4094
4095 -1
4096 };
4097
4098 static int32_t gamemisc2_list[] =
4099 {
4100 13,14,15,16,
4101 17,18,19,20,
4102
4103 45,46,47,48,
4104 49,50,51,52,
4105
4106 79,80,81,82,
4107 83,84,85,86,
4108
4109 -1
4110 };
4111
4112 static int32_t gamemisc3_list[] =
4113 {
4114 21,22,23,24,
4115 25,26,27,28,
4116
4117 53,54,55,56,
4118 57,58,59,60,
4119
4120 87,88,89,90,
4121 91,92,93,94,
4122
4123 -1
4124 };
4125
4126 static int32_t gamemisc4_list[] =
4127 {
4128 29,30,31,32,
4129 33,34,35,36,
4130
4131 61,62,63,64,
4132 65,66,67,68,
4133
4134 95,96,97,98,
4135 99,100,101,102,
4136
4137 -1
4138 };
4139
4140 static TABPANEL gamemisc_tabs[] =
4141 {
4142 // (text)
4143 { (char *)" Misc[0-7] ", D_SELECTED, gamemisc1_list, 0, NULL },
4144 { (char *)" Misc[8-15] ", 0, gamemisc2_list, 0, NULL },
4145 { (char *)" Misc[16-23] ", 0, gamemisc3_list, 0, NULL },
4146 { (char *)" Misc[24-31] ", 0, gamemisc4_list, 0, NULL },
4147 { NULL, 0, NULL, 0, NULL }
4148 };
4149
4150 //to do: Make string boxes larger, and split into two tabs.
4151 static DIALOG gamemiscarray_dlg[] =
4152 {
4153 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
4154
4155 { jwin_win_proc, 0, 10, 310, 224, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Game->Misc[]", NULL, NULL },
4156 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4157 { jwin_tab_proc, 3, 26, 304, 174, vc(14), vc(1), 0, 0, 1, 0, (void *) gamemisc_tabs, NULL, (void *)gamemiscarray_dlg },
4158 { d_dummy_proc, 240, 144, 40, 8, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
4159 { d_dummy_proc, 240, 144, 40, 8, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
4160
4161 //5
4162 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4163 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4164 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4165 //8
4166 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4167 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4168 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4169 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4170 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4171 //13
4172 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4173 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4174 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4175 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4176 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4177 //18
4178 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4179 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4180 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4181 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4182 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4183 //23
4184 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4185 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4186 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4187 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4188 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4189 //28
4190 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4191 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4192 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4193 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4194 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4195 //33
4196 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4197 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4198 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4199 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4200 //37
4201 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4202 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4203 //39
4204 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4205 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4206 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4207 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4208 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4209 //44
4210 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4211 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4212 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4213
4214 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4215 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4216 //49
4217 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4218 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4219 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4220 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4221 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4222 //54
4223 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4224 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4225 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4226 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4227 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4228 //59
4229 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4230 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4231 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4232 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4233 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4234 //64
4235 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4236 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4237 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4238 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4239 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4240 //69
4241 { jwin_button_proc, 70, 204, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
4242 { jwin_button_proc, 170, 204, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
4243
4244 //71
4245 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4246 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4247 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4248 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4249 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4250 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4251 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4252 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4253 //79
4254 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4255 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4256 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4257 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4258 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4259 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4260 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4261 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4262 //87
4263 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4264 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4265 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4266 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4267 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4268 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4269 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4270 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4271 //95
4272 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4273 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4274 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4275 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4276 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4277 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4278 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4279 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4280
4281 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
4282 };
4283
4284 // +----------+
4285 // | |
4286 // | View Pic |
4287 // | |
4288 // | |
4289 // | |
4290 // +----------+
4291
4292 BITMAP *pic=NULL;
4293 BITMAP *bmap=NULL;
4294 PALETTE picpal;
4295 PALETTE mappal;
4296 int32_t picx=0,picy=0,mapx=0,mapy=0,pblack,pwhite;
4297
4298 double picscale=1.0,mapscale=1.0;
4299 bool vp_showpal=true, vp_showsize=true, vp_center=true;
4300
4301 //INLINE int32_t pal_sum(RGB p) { return p.r + p.g + p.b; }
4302
4303 void get_bw(RGB *pal,int32_t &black,int32_t &white)
4304 {
4305 black=white=1;
4306
4307 for(int32_t i=1; i<256; i++)
4308 {
4309 if(pal_sum(pal[i])<pal_sum(pal[black]))
4310 black=i;
4311
4312 if(pal_sum(pal[i])>pal_sum(pal[white]))
4313 white=i;
4314 }
4315 }
4316
4317 void draw_bw_mouse(int32_t white, int32_t old_mouse, int32_t new_mouse)
4318 {
4319 blit(mouse_bmp[old_mouse][0],mouse_bmp[new_mouse][0],0,0,0,0,16,16);
4320
4321 for(int32_t y=0; y<16; y++)
4322 {
4323 for(int32_t x=0; x<16; x++)
4324 {
4325 if(getpixel(mouse_bmp[new_mouse][0],x,y)!=0)
4326 {
4327 putpixel(mouse_bmp[new_mouse][0],x,y,white);
4328 }
4329 }
4330 }
4331 }
4332
4333 int32_t load_the_pic(BITMAP **dst, PALETTE dstpal)
4334 {
4335 PALETTE temppal;
4336
4337 for(int32_t i=0; i<256; i++)
4338 {
4339 temppal[i]=dstpal[i];
4340 dstpal[i]=RAMpal[i];
4341 }
4342
4343 // set up the new palette
4344 for(int32_t i=0; i<64; i++)
4345 {
4346 dstpal[i].r = i;
4347 dstpal[i].g = i;
4348 dstpal[i].b = i;
4349 }
4350
4351 zc_set_palette(dstpal);
4352
4353 BITMAP *graypic = create_bitmap_ex(8,screen->w,screen->h);
4354 int32_t _w = screen->w-1;
4355 int32_t _h = screen->h-1;
4356
4357 // gray scale the current frame
4358 for(int32_t y=0; y<_h; y++)
4359 {
4360 for(int32_t x=0; x<_w; x++)
4361 {
4362 int32_t c = screen->line[y][x];
4363 int32_t gray = zc_min((temppal[c].r*42 + temppal[c].g*75 + temppal[c].b*14) >> 7, 63);
4364 graypic->line[y][x] = gray;
4365 }
4366 }
4367
4368 blit(graypic,screen,0,0,0,0,screen->w,screen->h);
4369 destroy_bitmap(graypic);
4370 #ifdef __GNUC__
4371 #pragma GCC diagnostic ignored "-Wformat-overflow"
4372 #endif
4373 char extbuf[2][80];
4374 memset(extbuf[0],0,80);
4375 memset(extbuf[1],0,80);
4376 sprintf(extbuf[0], "View Image (%s", snapshotformat_str[0][1]);
4377 strcpy(extbuf[1], snapshotformat_str[0][1]);
4378
4379 for(int32_t i=1; i<ssfmtMAX; ++i)
4380 {
4381 sprintf(extbuf[0], "%s, %s", extbuf[0], snapshotformat_str[i][1]);
4382 sprintf(extbuf[1], "%s;%s", extbuf[1], snapshotformat_str[i][1]);
4383 }
4384
4385 sprintf(extbuf[0], "%s)", extbuf[0]);
4386 #ifdef __GNUC__
4387 #pragma GCC diagnostic pop
4388 #endif
4389
4390 int32_t gotit = prompt_for_existing_file_compat(extbuf[0],extbuf[1],NULL,imagepath,true);
4391
4392 if(!gotit)
4393 {
4394 zc_set_palette(temppal);
4395 get_palette(dstpal);
4396 return 1;
4397 }
4398
4399 strcpy(imagepath,temppath);
4400
4401 if(*dst)
4402 {
4403 destroy_bitmap(*dst);
4404 }
4405
4406 for(int32_t i=0; i<256; i++)
4407 {
4408 dstpal[i].r = 0;
4409 dstpal[i].g = 0;
4410 dstpal[i].b = 0;
4411 }
4412
4413 *dst = load_bitmap(imagepath,picpal);
4414
4415 if(!*dst)
4416 {
4417 jwin_alert("Error","Error loading image:",imagepath,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4418 return 2;
4419 }
4420
4421 // get_bw(picpal,pblack,pwhite);
4422 // draw_bw_mouse(pwhite);
4423 // gui_bg_color = pblack;
4424 // gui_fg_color = pwhite;
4425
4426 if(vp_center)
4427 {
4428 picx=picy=0;
4429 }
4430 else
4431 {
4432 picx=(*dst)->w-zq_screen_w;
4433 picy=(*dst)->h-zq_screen_h;
4434 }
4435
4436 return 0;
4437 }
4438 int load_the_pic_new(BITMAP **dst, PALETTE dstpal)
4439 {
4440 #ifdef __GNUC__
4441 #pragma GCC diagnostic ignored "-Wformat-overflow"
4442 #endif
4443 char extbuf[2][80];
4444 memset(extbuf[0],0,80);
4445 memset(extbuf[1],0,80);
4446 sprintf(extbuf[0], "View Image (%s", snapshotformat_str[0][1]);
4447 strcpy(extbuf[1], snapshotformat_str[0][1]);
4448
4449 for(int32_t i=1; i<ssfmtMAX; ++i)
4450 {
4451 sprintf(extbuf[0], "%s, %s", extbuf[0], snapshotformat_str[i][1]);
4452 sprintf(extbuf[1], "%s;%s", extbuf[1], snapshotformat_str[i][1]);
4453 }
4454
4455 sprintf(extbuf[0], "%s)", extbuf[0]);
4456 #ifdef __GNUC__
4457 #pragma GCC diagnostic pop
4458 #endif
4459
4460 int32_t gotit = prompt_for_existing_file_compat(extbuf[0],extbuf[1],NULL,imagepath,true);
4461
4462 if(!gotit)
4463 return 1;
4464
4465 strcpy(imagepath,temppath);
4466
4467 if(*dst)
4468 destroy_bitmap(*dst);
4469
4470 for(int32_t i=0; i<256; i++)
4471 {
4472 dstpal[i].r = 0;
4473 dstpal[i].g = 0;
4474 dstpal[i].b = 0;
4475 }
4476
4477 *dst = load_bitmap(imagepath,dstpal);
4478
4479 if(!*dst)
4480 {
4481 jwin_alert("Error","Error loading image:",imagepath,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4482 return 2;
4483 }
4484
4485 if(vp_center)
4486 {
4487 picx=picy=0;
4488 }
4489 else
4490 {
4491 picx=(*dst)->w-zq_screen_w;
4492 picy=(*dst)->h-zq_screen_h;
4493 }
4494
4495 return 0;
4496 }
4497
4498 int32_t saveMapAsImage(ALLEGRO_BITMAP* bitmap)
4499 {
4500 char buf[200];
4501 int32_t num=0;
4502
4503 do
4504 {
4505 snprintf(buf, 200, "%szquest_map%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
4506 buf[199]='\0';
4507 }
4508 while(num<99999 && exists(buf));
4509
4510 if (!al_save_bitmap(buf, bitmap))
4511 InfoDialog("Error", "Failed to save map image").show();
4512
4513 return D_O_K;
4514 }
4515
4516 int32_t onViewPic()
4517 {
4518 return launchPicViewer(&pic,picpal,&picx,&picy,&picscale,false);
4519 }
4520
4521
4522 class MapViewRTI : public RenderTreeItem
4523 {
4524 public:
4525
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 MapViewRTI(): RenderTreeItem("map_view")
4526 12 {
4527 12 }
4528
4529 int bw, bh, sw, sh, flags;
4530
4531 private:
4532 void render(bool bitmap_resized)
4533 {
4534 MapCursor previous_cursor = Map.getCursor();
4535 Map.setViewSize(1);
4536
4537 BITMAP* bmap4_single = create_bitmap_ex(8,256,176);
4538 set_bitmap_create_flags(true);
4539 ALLEGRO_BITMAP* bmap5_single = al_create_bitmap(256,176);
4540 for(int32_t y=0; y<8; y++)
4541 {
4542 for(int32_t x=0; x<16; x++)
4543 {
4544 clear_bitmap(bmap4_single);
4545 Map.setCurrScr(y*16+x);
4546 Map.draw(bmap4_single, 0, 0, flags, -1, y*16+x, -1);
4547 stretch_blit(bmap4_single, bmap4_single, 0, 0, 0, 0, 256, 176, 256, 176);
4548 all_render_a5_bitmap(bmap4_single, bmap5_single);
4549 al_draw_scaled_bitmap(bmap5_single, 0, 0, 256, 176, sw * x, sh * y, sw, sh, 0);
4550 }
4551 }
4552
4553 Map.setCursor(previous_cursor);
4554 destroy_bitmap(bmap4_single);
4555 al_destroy_bitmap(bmap5_single);
4556 }
4557 };
4558 12 static MapViewRTI rti_map_view;
4559
4560 int32_t launchPicViewer(BITMAP **pictoview, PALETTE pal, int32_t *px2, int32_t *py2, double *scale2, bool isviewingmap, bool skipmenu)
4561 {
4562 restore_mouse();
4563 BITMAP *buf;
4564 bool done=false, redraw=true;
4565
4566 popup_zqdialog_start();
4567
4568 // Always call load_the_map() when viewing the map.
4569 if((!*pictoview || isviewingmap) && (isviewingmap ? load_the_map(skipmenu) : load_the_pic(pictoview,pal)))
4570 {
4571 zc_set_palette(RAMpal);
4572 popup_zqdialog_end();
4573 close_the_map();
4574 return D_O_K;
4575 }
4576
4577 get_bw(pal,pblack,pwhite);
4578
4579 int32_t oldfgcolor = gui_fg_color;
4580 int32_t oldbgcolor = gui_bg_color;
4581
4582 buf = create_bitmap_ex(8,zq_screen_w,zq_screen_h);
4583
4584 if(!buf)
4585 {
4586 jwin_alert("Error","Error creating temp bitmap",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4587 popup_zqdialog_end();
4588 close_the_map();
4589 return D_O_K;
4590 }
4591
4592 static LegacyBitmapRTI viewer_overlay_rti("viewer_overlay");
4593 viewer_overlay_rti.set_size(buf->w, buf->h);
4594 viewer_overlay_rti.a4_bitmap = buf;
4595 viewer_overlay_rti.transparency_index = 15;
4596 get_root_rti()->add_child(&viewer_overlay_rti);
4597
4598 zc_set_palette(pal);
4599
4600 if(isviewingmap)
4601 {
4602 set_center_root_rti(false);
4603
4604 int sw = rti_map_view.width / 16;
4605 int sh = rti_map_view.height / 8;
4606 int screen = Map.getCurrScr();
4607 if (screen >= 0x00 && screen <= 0x7F)
4608 {
4609 auto root_transform = get_root_rti()->get_transform();
4610 int dw = al_get_display_width(all_get_display()) / root_transform.xscale;
4611 int dh = al_get_display_height(all_get_display()) / root_transform.yscale;
4612 mapx = (-(screen % 16) * sw - sw/2 + dw/2);
4613 mapy = (-(screen / 16) * sh - sh/2 + dh/2);
4614 }
4615 }
4616
4617 do
4618 {
4619 int w, h;
4620 if (isviewingmap)
4621 {
4622 w = rti_map_view.width;
4623 h = rti_map_view.height;
4624 }
4625 else
4626 {
4627 w = (*pictoview)->w;
4628 h = (*pictoview)->h;
4629 }
4630
4631 if (isviewingmap)
4632 {
4633 float scale = *scale2;
4634 auto root_transform = get_root_rti()->get_transform();
4635 int dw = al_get_display_width(all_get_display()) / root_transform.xscale;
4636 int dh = al_get_display_height(all_get_display()) / root_transform.yscale;
4637 mapx = std::max(mapx, (int)(-w*scale + dw));
4638 mapy = std::max(mapy, (int)(-h*scale + dh));
4639 mapx = std::min(mapx, 0);
4640 mapy = std::min(mapy, 0);
4641 rti_map_view.set_transform({mapx, mapy, scale, scale});
4642 }
4643
4644 if(redraw)
4645 {
4646 clear_to_color(buf,15);
4647
4648 if (!isviewingmap)
4649 stretch_blit(*pictoview, buf, 0, 0, w, h,
4650 int32_t(zq_screen_w + (*px2 - w) * *scale2) / 2, int32_t(zq_screen_h + (*py2 - h) * *scale2) / 2,
4651 int32_t(w * *scale2), int32_t(h * *scale2));
4652
4653 if(vp_showpal)
4654 for(int32_t i=0; i<256; i++)
4655 rectfill(buf,((i&15)<<2)+zq_screen_w-64,((i>>4)<<2)+zq_screen_h-64,((i&15)<<2)+zq_screen_w-64+3,((i>>4)<<2)+zq_screen_h-64+3,i);
4656
4657 if(vp_showsize)
4658 {
4659 textprintf_ex(buf,font,0,zq_screen_h-8,pwhite,pblack,"%dx%d %.2f%%",w,h,*scale2*100.0);
4660 }
4661
4662 if (!isviewingmap)
4663 blit(buf,screen,0,0,0,0,zq_screen_w,zq_screen_h);
4664 redraw=false;
4665 }
4666
4667 custom_vsync();
4668
4669 int32_t step = 16;
4670
4671 if(*scale2 < 1.0)
4672 step = int32_t(4.0/ *scale2);
4673
4674 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
4675 step <<= 2;
4676
4677 if(CHECK_CTRL_CMD)
4678 step >>= 1;
4679
4680 if(key[KEY_UP])
4681 {
4682 *py2+=step;
4683 redraw=true;
4684 }
4685
4686 if(key[KEY_DOWN])
4687 {
4688 *py2-=step;
4689 redraw=true;
4690 }
4691
4692 if(key[KEY_LEFT])
4693 {
4694 *px2+=step;
4695 redraw=true;
4696 }
4697
4698 if(key[KEY_RIGHT])
4699 {
4700 *px2-=step;
4701 redraw=true;
4702 }
4703
4704 if(keypressed() && !redraw)
4705 switch(readkey()>>8)
4706 {
4707 case KEY_PGUP:
4708 *scale2*=0.95;
4709
4710 if(*scale2<0.1) *scale2=0.1;
4711
4712 redraw=true;
4713 break;
4714
4715 case KEY_PGDN:
4716 *scale2/=0.95;
4717
4718 if(*scale2>5.0) *scale2=5.0;
4719
4720 redraw=true;
4721 break;
4722
4723 case KEY_HOME:
4724 *scale2/=2.0;
4725
4726 if(*scale2<0.1) *scale2=0.1;
4727
4728 redraw=true;
4729 break;
4730
4731 case KEY_END:
4732 *scale2*=2.0;
4733
4734 if(*scale2>5.0) *scale2=5.0;
4735
4736 redraw=true;
4737 break;
4738
4739 case KEY_TILDE:
4740 *scale2=0.5;
4741 redraw=true;
4742 break;
4743
4744 case KEY_Z:
4745 *px2=w-zq_screen_w;
4746 *py2=h-zq_screen_h;
4747 vp_center=false;
4748 redraw=true;
4749 break;
4750
4751 case KEY_1:
4752 *scale2=1.0;
4753 redraw=true;
4754 break;
4755
4756 case KEY_2:
4757 *scale2=2.0;
4758 redraw=true;
4759 break;
4760
4761 case KEY_3:
4762 *scale2=3.0;
4763 redraw=true;
4764 break;
4765
4766 case KEY_4:
4767 *scale2=4.0;
4768 redraw=true;
4769 break;
4770
4771 case KEY_5:
4772 *scale2=5.0;
4773 redraw=true;
4774 break;
4775
4776 case KEY_C:
4777 *px2=*py2=0;
4778 redraw=vp_center=true;
4779 break;
4780
4781 case KEY_S:
4782 vp_showsize = !vp_showsize;
4783 redraw=true;
4784 break;
4785
4786 case KEY_D:
4787 vp_showpal = !vp_showpal;
4788 redraw=true;
4789 break;
4790
4791 case KEY_P:
4792 if(isviewingmap) break;
4793
4794 case KEY_ESC:
4795 done=true;
4796 break;
4797
4798 case KEY_SPACE:
4799 close_the_map();
4800 // TODO: why is `load_the_map` rendering a black dialog?
4801 if(isviewingmap ? load_the_map(skipmenu) : load_the_pic(pictoview,pal)==2)
4802 {
4803 done=true;
4804 }
4805 else
4806 {
4807 redraw=true;
4808 gui_bg_color = pblack;
4809 gui_fg_color = pwhite;
4810 *scale2=1.0;
4811 zc_set_palette(pal);
4812 }
4813
4814 get_bw(pal,pblack,pwhite);
4815 break;
4816 }
4817 }
4818 while(!done);
4819
4820 destroy_bitmap(buf);
4821 zc_set_palette(RAMpal);
4822 gui_fg_color = oldfgcolor;
4823 gui_bg_color = oldbgcolor;
4824
4825 popup_zqdialog_end();
4826 position_mouse_z(0);
4827 viewer_overlay_rti.remove();
4828 set_center_root_rti(true);
4829 close_the_map();
4830 return D_O_K;
4831 }
4832
4833 static DIALOG loadmap_dlg[] =
4834 {
4835 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
4836 { jwin_win_proc, 0, 0, 225, 143, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "View Map", NULL, NULL },
4837 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4838 { jwin_text_proc, 32, 26, 96, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Resolution", NULL, NULL },
4839 // 3
4840 { jwin_radio_proc, 16, 36, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "1/4 - 1024x352", NULL, NULL },
4841 { jwin_radio_proc, 16, 46, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "1/2 - 2048x704", NULL, NULL },
4842 { jwin_radio_proc, 16, 56, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Full - 4096x1408", NULL, NULL },
4843 { jwin_text_proc, 144, 26, 97, 9, vc(11), vc(1), 0, 0, 0, 0, (void *) "Options", NULL, NULL },
4844 // 7
4845 { jwin_check_proc, 144, 36, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Solidity", NULL, NULL },
4846 { jwin_check_proc, 144, 46, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Flags", NULL, NULL },
4847 { jwin_check_proc, 144, 56, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Dark", NULL, NULL },
4848 { jwin_check_proc, 144, 66, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Items", NULL, NULL },
4849 // 11
4850 { jwin_button_proc, 42, 110, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
4851 { jwin_button_proc, 122, 110, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
4852 { jwin_check_proc, 16, 88, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Save to Image", NULL, NULL },
4853 // 14
4854 { jwin_radio_proc, 16, 66, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void*)"2x - 8192x2816", NULL, NULL },
4855 { jwin_radio_proc, 16, 76, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void*)"4x - 16384x5632", NULL, NULL },
4856 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
4857 };
4858
4859 int32_t load_the_map(bool skipmenu)
4860 {
4861 static int32_t res = 0;
4862 static int32_t flags = cDEBUG;
4863
4864 loadmap_dlg[0].dp2 = get_zc_font(font_lfont);
4865 loadmap_dlg[3].flags = (res==2) ? D_SELECTED : 0;
4866 loadmap_dlg[4].flags = (res==1) ? D_SELECTED : 0;
4867 loadmap_dlg[5].flags = (res==0) ? D_SELECTED : 0;
4868 loadmap_dlg[7].flags = (flags&cWALK) ? D_SELECTED : 0;
4869 loadmap_dlg[8].flags = (flags&cFLAGS) ? D_SELECTED : 0;
4870 loadmap_dlg[9].flags = (flags&cNODARK) ? 0 : D_SELECTED;
4871 loadmap_dlg[10].flags = (flags&cNOITEM) ? 0 : D_SELECTED;
4872 loadmap_dlg[13].flags = 0;
4873 loadmap_dlg[14].flags = (res==3) ? D_SELECTED : 0;
4874 loadmap_dlg[15].flags = (res==4) ? D_SELECTED : 0;
4875
4876 if(!skipmenu)
4877 {
4878 large_dialog(loadmap_dlg);
4879
4880 if (do_zqdialog(loadmap_dlg, 11) != 11)
4881 {
4882 return 1;
4883 }
4884
4885 flags = cDEBUG;
4886
4887 if(loadmap_dlg[3].flags&D_SELECTED) res=2;
4888
4889 if(loadmap_dlg[4].flags&D_SELECTED) res=1;
4890
4891 if(loadmap_dlg[5].flags&D_SELECTED) res=0;
4892
4893 if(loadmap_dlg[7].flags&D_SELECTED) flags|=cWALK;
4894
4895 if(loadmap_dlg[8].flags&D_SELECTED) flags|=cFLAGS;
4896
4897 if(!(loadmap_dlg[9].flags&D_SELECTED)) flags|=cNODARK;
4898
4899 if(!(loadmap_dlg[10].flags&D_SELECTED)) flags|=cNOITEM;
4900
4901 if(loadmap_dlg[14].flags&D_SELECTED) res=3;
4902
4903 if(loadmap_dlg[15].flags&D_SELECTED) res=4;
4904 }
4905
4906 int32_t bw = (256*16)>>res;
4907 int32_t bh = (176*8)>>res;
4908 int32_t sw = 256>>res;
4909 int32_t sh = 176>>res;
4910 if(res>2)
4911 {
4912 bw = (256*16)<<(res-2);
4913 bh = (176*8)<<(res-2);
4914 sw = 256<<(res-2);
4915 sh = 176<<(res-2);
4916 }
4917
4918 rti_map_view.flags = flags;
4919 rti_map_view.bw = bw;
4920 rti_map_view.bh = bh;
4921 rti_map_view.sw = sw;
4922 rti_map_view.sh = sh;
4923 rti_map_view.set_size(bw, bh);
4924 rti_map_view.dirty = true;
4925 get_root_rti()->add_child(&rti_map_view);
4926 render_zq();
4927
4928 vp_showpal = false;
4929 get_bw(picpal,pblack,pwhite);
4930 mapx = mapy = 0;
4931 mapscale = 1;
4932 imagepath[0] = 0;
4933
4934 if(loadmap_dlg[13].flags & D_SELECTED) saveMapAsImage(rti_map_view.bitmap);
4935
4936 memcpy(mappal,RAMpal,sizeof(RAMpal));
4937
4938 return 0;
4939 }
4940
4941 void close_the_map()
4942 {
4943 rti_map_view.remove();
4944 }
4945
4946 int32_t onViewMap()
4947 {
4948 return onViewMapEx(false);
4949 }
4950 int32_t onViewMapEx(bool skipmenu)
4951 {
4952 int32_t temp_aligns=ShowMisalignments;
4953 ShowMisalignments=0;
4954 //if(load_the_map()==0)
4955 //{
4956 launchPicViewer(&bmap,mappal,&mapx, &mapy, &mapscale,true,skipmenu);
4957 //}
4958 ShowMisalignments=temp_aligns;
4959 return D_O_K;
4960 }
4961
4962 static const char *mazedirstr[4] = {"North","South","West","East"};
4963 char _pathstr[40]="North,North,North,North";
4964
4965 char *pathstr(byte path[])
4966 {
4967 sprintf(_pathstr,"%s,%s,%s,%s",mazedirstr[path[0]],mazedirstr[path[1]],
4968 mazedirstr[path[2]],mazedirstr[path[3]]);
4969 return _pathstr;
4970 }
4971
4972 char _ticksstr[32]="99.99 seconds";
4973
4974 char *ticksstr(int32_t tics)
4975 {
4976 int32_t mins=tics/(60*60);
4977 tics=tics-(mins*60*60);
4978 int32_t secs=tics/60;
4979 tics=tics-(secs*60);
4980 tics=tics*100/60;
4981
4982 if(mins>0)
4983 {
4984 sprintf(_ticksstr,"%d:%02d.%02d",mins, secs, tics);
4985 }
4986 else
4987 {
4988 sprintf(_ticksstr,"%d.%02d seconds",secs, tics);
4989 }
4990
4991 return _ticksstr;
4992 }
4993 void textprintf_disabled(BITMAP *bmp, AL_CONST FONT *f, int32_t x, int32_t y, int32_t color_hl, int32_t color_sh, AL_CONST char *format, ...)
4994 {
4995 char buf[512];
4996 va_list ap;
4997 ASSERT(bmp);
4998 ASSERT(f);
4999 ASSERT(format);
5000
5001 va_start(ap, format);
5002 uvszprintf(buf, sizeof(buf), format, ap);
5003 va_end(ap);
5004
5005
5006 textout_ex(bmp, f, buf, x+1, y+1, color_hl, -1);
5007
5008 textout_ex(bmp, f, buf, x, y, color_sh, -1);
5009 }
5010
5011 void textprintf_centre_disabled(BITMAP *bmp, AL_CONST FONT *f, int32_t x, int32_t y, int32_t color_hl, int32_t color_sh, AL_CONST char *format, ...)
5012 {
5013 char buf[512];
5014 va_list ap;
5015 ASSERT(bmp);
5016 ASSERT(f);
5017 ASSERT(format);
5018
5019 va_start(ap, format);
5020 uvszprintf(buf, sizeof(buf), format, ap);
5021 va_end(ap);
5022
5023 textout_centre_ex(bmp, f, buf, x+1, y+1, color_hl, -1);
5024 textout_centre_ex(bmp, f, buf, x, y, color_sh, -1);
5025 }
5026
5027 void draw_sqr_frame(size_and_pos const& sqr)
5028 {
5029 jwin_draw_frame(menu1,sqr.x,sqr.y,sqr.tw(),sqr.th(),FR_DEEP);
5030 }
5031 void draw_sqr_icon(size_and_pos const& sqr, BITMAP* icon)
5032 {
5033 stretch_blit(icon, menu1, 0, 0, 16, 16, sqr.x+2, sqr.y+2, sqr.tw()-4, sqr.th()-4);
5034 }
5035 void draw_sqr_nums(size_and_pos const& sqr, FONT* f, bool center, int num)
5036 {
5037 if(center)
5038 textprintf_centre_ex(menu1,f,sqr.x+txtoffs_single.x,sqr.y+txtoffs_single.y,jwin_pal[jcBOXFG],-1,"%d",num);
5039 else
5040 textprintf_ex(menu1,f,sqr.x+txtoffs_single.x,sqr.y+txtoffs_single.y,jwin_pal[jcBOXFG],-1,"%d",num);
5041 }
5042 void draw_sqr_nums(size_and_pos const& sqr, FONT* f, bool center, int num1, int num2)
5043 {
5044 if(center)
5045 {
5046 textprintf_centre_ex(menu1,f,sqr.x+txtoffs_double_1.x,sqr.y+txtoffs_double_1.y,jwin_pal[jcBOXFG],-1,"%d",num1);
5047 textprintf_centre_ex(menu1,f,sqr.x+txtoffs_double_2.x,sqr.y+txtoffs_double_2.y,jwin_pal[jcBOXFG],-1,"%d",num2);
5048 }
5049 else
5050 {
5051 textprintf_ex(menu1,f,sqr.x+txtoffs_double_1.x,sqr.y+txtoffs_double_1.y,jwin_pal[jcBOXFG],-1,"%d",num1);
5052 textprintf_ex(menu1,f,sqr.x+txtoffs_double_2.x,sqr.y+txtoffs_double_2.y,jwin_pal[jcBOXFG],-1,"%d",num2);
5053 }
5054 }
5055 void draw_sqr_btn(size_and_pos const& sqr, const char* txt, int flags, FONT* f = nullptr)
5056 {
5057 if(sqr.x < 0) return;
5058 FONT* tfont = font;
5059 if(f)
5060 font = f;
5061 draw_text_button(menu1, sqr.x, sqr.y, sqr.tw(), sqr.th(), txt, 0, 0, flags, true);
5062 font = tfont;
5063 }
5064 void draw_sqr_btn(size_and_pos const& sqr, int icon, int flags, FONT* f = nullptr)
5065 {
5066 if(sqr.x < 0) return;
5067 FONT* tfont = font;
5068 if(f)
5069 font = f;
5070 draw_icon_button(menu1, sqr.x, sqr.y, sqr.tw(), sqr.th(), icon, 0, 0, flags, true);
5071 font = tfont;
5072 }
5073
5074 void drawpanel()
5075 {
5076 mapscr *scr=Map.CurrScr();
5077 int32_t NextCombo = combobuf[Combo].nextcombo;
5078 int32_t NextCSet = combobuf[Combo].nextcset;
5079 if(combobuf[Combo].animflags & AF_CYCLEUNDERCOMBO)
5080 {
5081 NextCombo = scr->undercombo;
5082 NextCSet = scr->undercset;
5083 }
5084 if(combobuf[Combo].animflags & AF_CYCLENOCSET)
5085 NextCSet = CSet;
5086
5087 FONT* tfont = font;
5088 if(prv_mode)
5089 {
5090 jwin_draw_frame(menu1,0,preview_panel.y,preview_panel.x+preview_panel.w, preview_panel.h, FR_WIN);
5091 rectfill(menu1,preview_panel.x,preview_panel.y+2,preview_panel.x+preview_panel.w-3,preview_panel.y+preview_panel.h-3,jwin_pal[jcBOX]);
5092 }
5093 else
5094 {
5095 auto& sqr = main_panel;
5096 rectfill(menu1,sqr.x,sqr.y,sqr.x+sqr.w-1,sqr.y+sqr.h-1, jwin_pal[jcBOX]);
5097 refresh(rSCRMAP);
5098 jwin_draw_frame(menu1,sqr.x,sqr.y,sqr.w,sqr.h, FR_WIN);
5099
5100 font = get_custom_font(CFONT_GUI);
5101 draw_sqr_btn(squarepanel_swap_btn, "SWP", 0);
5102 if(compact_square_panels)
5103 {
5104 textprintf_centre_ex(menu1,font,squarepanel_up_btn.cx(),squarepanel_up_btn.y-text_height(font)-2,jwin_pal[jcBOXFG],-1,"%d",compact_active_panel);
5105 draw_sqr_btn(squarepanel_up_btn, BTNICON_ARROW_UP, 0);
5106 draw_sqr_btn(squarepanel_down_btn, BTNICON_ARROW_DOWN, 0);
5107 }
5108 font = tfont;
5109
5110 FONT* sqr_text_font = (is_compact && compact_square_panels) ? get_custom_font(CFONT_GUI) : font;
5111 //Item:
5112 if(itemsqr_pos.x > -1)
5113 {
5114 draw_sqr_frame(itemsqr_pos);
5115 if(scr->hasitem)
5116 {
5117 rectfill(menu1,itemsqr_pos.x+2,itemsqr_pos.y+2,itemsqr_pos.x+itemsqr_pos.tw()-3,itemsqr_pos.y+itemsqr_pos.th()-3,0);
5118 overtile16_scale(menu1, itemsbuf[scr->item].tile,itemsqr_pos.x+2,itemsqr_pos.y+2,itemsbuf[scr->item].csets&15,0,itemsqr_pos.tw()-4,itemsqr_pos.th()-4);
5119 }
5120 else draw_sqr_icon(itemsqr_pos, icon_bmp[0][coord_frame]);
5121 draw_sqr_nums(itemsqr_pos, sqr_text_font, panel_align == 1, scr->itemx, scr->itemy);
5122 }
5123 //Flag:
5124 if(flagsqr_pos.x > -1)
5125 {
5126 draw_sqr_frame(flagsqr_pos);
5127 draw_sqr_icon(flagsqr_pos,flag_bmp[Flag%16][coord_frame]);
5128 draw_sqr_nums(flagsqr_pos, sqr_text_font, panel_align == 1, Flag);
5129 }
5130
5131 //Stairs:
5132 if(stairsqr_pos.x > -1)
5133 {
5134 draw_sqr_frame(stairsqr_pos);
5135 draw_sqr_icon(stairsqr_pos,icon_bmp[1][coord_frame]);
5136 draw_sqr_nums(stairsqr_pos, sqr_text_font, panel_align == 1, scr->stairx, scr->stairy);
5137 }
5138
5139 //Green arrival square:
5140 bool disabled_arrival = get_qr(qr_NOARRIVALPOINT);
5141 if(warparrival_pos.x > -1)
5142 {
5143 draw_sqr_frame(warparrival_pos);
5144 BITMAP* icon = icon_bmp[2][coord_frame];
5145 if(disabled_arrival)
5146 {
5147 icon = create_bitmap_ex(8,16,16);
5148 blit(icon_bmp[2][0], icon, 0, 0, 0, 0, 16, 16);
5149 replColor(icon, 0xE7, 0xEA, 0xEA, false);
5150 replColor(icon, 0xE8, 0xE2, 0xE2, false);
5151 }
5152
5153 draw_sqr_icon(warparrival_pos, icon);
5154 draw_sqr_nums(warparrival_pos, sqr_text_font, panel_align == 1, scr->warparrivalx, scr->warparrivaly);
5155
5156 if(disabled_arrival)
5157 destroy_bitmap(icon);
5158 }
5159
5160 //Blue return squares:
5161 for(int32_t i=0; i<4; i++)
5162 {
5163 if(warpret_pos[i].x < 0) continue;
5164 draw_sqr_frame(warpret_pos[i]);
5165 draw_sqr_icon(warpret_pos[i], icon_bmp[ICON_BMP_RETURN_A+i][coord_frame]);
5166 draw_sqr_nums(warpret_pos[i], sqr_text_font, panel_align == 1, scr->warpreturnx[i], scr->warpreturny[i]);
5167 }
5168
5169 // Enemies
5170 auto& ep = enemy_prev_pos;
5171 if(ep.x > -1)
5172 {
5173 if(ep.fw > -1)
5174 {
5175 rectfill(menu1, ep.x, ep.y, ep.x+ep.tw()-1,ep.y+ep.th()-1,vc(0));
5176 rectfill(menu1, ep.x+ep.fw, ep.y+ep.fh, ep.x+ep.tw()-1, ep.y+ep.th()-1, jwin_pal[jcBOX]);
5177 jwin_draw_frag_frame(menu1, ep.x, ep.y, ep.tw(), ep.th(), ep.fw, ep.fh, FR_DEEP);
5178 }
5179 else
5180 {
5181 rectfill(menu1, ep.x, ep.y, ep.x+ep.tw()-1,ep.y+ep.th()-1,vc(0));
5182 draw_sqr_frame(ep);
5183 }
5184 for(int32_t i=0; i< 10 && Map.CurrScr()->enemy[i]!=0; i++)
5185 {
5186 int32_t id = Map.CurrScr()->enemy[i];
5187 int32_t tile = get_qr(qr_NEWENEMYTILES) ? guysbuf[id].e_tile : guysbuf[id].tile;
5188 int32_t cset = guysbuf[id].cset;
5189 auto& sqr = ep.subsquare(i);
5190 if(tile)
5191 overtile16_scale(menu1, tile+efrontfacingtile(id),sqr.x,sqr.y,cset,0,sqr.tw(),sqr.th());
5192 }
5193 }
5194 }
5195 font = tfont;
5196 }
5197
5198 void show_screen_error(const char *str, int32_t i, int32_t c)
5199 {
5200 rectfill(menu1, screrrorpos.x-text_length(get_zc_font(font_lfont_l),str),screrrorpos.y-(i*16),screrrorpos.x,screrrorpos.y-((i-1)*16)-4,vc(0));
5201 textout_shadowed_ex(menu1,get_zc_font(font_lfont_l), str,screrrorpos.x-text_length(get_zc_font(font_lfont_l),str),screrrorpos.y-(i*16),c,vc(0),-1);
5202 }
5203
5204 void tile_warp_notification(int32_t which, char *buf)
5205 {
5206 char letter = 'A'+which;
5207
5208 switch(Map.CurrScr()->tilewarptype[which])
5209 {
5210 case wtCAVE:
5211 sprintf(buf,"Tile Warp %c: Cave/Item Cellar",letter);
5212 break;
5213
5214 default:
5215 {
5216 char buf2[30];
5217
5218 if(strlen(DMaps[Map.CurrScr()->tilewarpdmap[which]].name)==0)
5219 {
5220 sprintf(buf2,"%d",Map.CurrScr()->tilewarpdmap[which]);
5221 }
5222 else
5223 sprintf(buf2,"%d-%s",Map.CurrScr()->tilewarpdmap[which],DMaps[Map.CurrScr()->tilewarpdmap[which]].name);
5224
5225 sprintf(buf,"Tile Warp %c: %s, %02X", letter, buf2, Map.CurrScr()->tilewarpscr[which]);
5226 break;
5227 }
5228
5229 case wtNOWARP:
5230 sprintf(buf,"Tile Warp %c: Cancel Warp", letter);
5231 break;
5232 }
5233 }
5234
5235 void side_warp_notification(int32_t which, int32_t dir, char *buf)
5236 {
5237 char letter = 'A'+which;
5238 char buf3[16];
5239
5240 if(dir==0 && Map.CurrScr()->timedwarptics)
5241 sprintf(buf3,"%s, Timed",mazedirstr[dir]);
5242 else if(dir==4)
5243 sprintf(buf3,"Timed");
5244 else
5245 strcpy(buf3, mazedirstr[dir]);
5246
5247 switch(Map.CurrScr()->sidewarptype[which])
5248 {
5249 case wtCAVE:
5250 sprintf(buf,"Side Warp %c (%s): Cave/Item Cellar",letter, buf3);
5251 break;
5252
5253 default:
5254 {
5255 // Destination DMap name
5256 if(strlen(DMaps[Map.CurrScr()->sidewarpdmap[which]].name)==0)
5257 {
5258 sprintf(buf,"Side Warp %c (%s): %d, %02X", letter, buf3, Map.CurrScr()->sidewarpdmap[which], Map.CurrScr()->sidewarpscr[which]);
5259 }
5260 else
5261 sprintf(buf,"Side Warp %c (%s): %d-%s, %02X", letter, buf3, Map.CurrScr()->sidewarpdmap[which],DMaps[Map.CurrScr()->sidewarpdmap[which]].name, Map.CurrScr()->sidewarpscr[which]);
5262
5263 break;
5264 }
5265
5266 case wtNOWARP:
5267 sprintf(buf,"Side Warp %c (%s): Cancel Warp", letter, buf3);
5268 break;
5269 }
5270 }
5271
5272 static bool arrowcursor = true; // Used by combo aliases and Combo Brush cursors. -L
5273
5274 void xout(BITMAP* dest, int x, int y, int x2, int y2, int c, int bgc = -1)
5275 {
5276 //BG Fill
5277 if(bgc > -1)
5278 rectfill(dest, x, y, x2, y2, bgc);
5279 ++x; ++y; --x2; --y2;
5280 //Border
5281 safe_rect(dest, x, y, x2, y2, c);
5282 //line(dest, x, y, x2, y, c);
5283 //line(dest, x, y, x, y2, c);
5284 //X
5285 line(dest, x, y, x2, y2, c);
5286 line(dest, x, y2, x2, y, c);
5287 }
5288
5289 void put_autocombo_engravings(BITMAP* dest, combo_auto const& ca, bool selected, int32_t x, int32_t y, int32_t scale)
5290 {
5291 if (!ca.valid())
5292 {
5293 if (ca.getDisplay() > 0)
5294 put_engraving(dest, x, y, 15, scale);
5295 }
5296 else
5297 {
5298 if (ca.getType() == AUTOCOMBO_Z4 || ca.getType() == AUTOCOMBO_DOR)
5299 {
5300 byte hei = vbound(ca.getArg() + 1, 1, 9);
5301 if (selected)
5302 hei = vbound(cauto_height, 1, 9);
5303 put_engraving(dest, x, y, 15 - hei, scale);
5304 }
5305 }
5306 }
5307
5308 void draw_screenunit_map_screen(VisibleScreen visible_screen)
5309 {
5310 int num_screens_to_draw = Map.getViewSize();
5311 int screen = visible_screen.screen;
5312 int xoff = visible_screen.xoff;
5313 int yoff = visible_screen.yoff;
5314
5315 mapscr* scr = visible_screen.scr;
5316 if (!layers_valid(scr))
5317 fix_layers(scr, true);
5318
5319 clear_to_color(mapscreenbmp, jwin_pal[jcBOX]);
5320 if (LayerDitherBG > -1)
5321 {
5322 if (LayerDitherSz > 0)
5323 ditherblit(mapscreenbmp, nullptr, vc(LayerDitherBG), dithChecker, LayerDitherSz);
5324 else
5325 clear_to_color(mapscreenbmp, vc(LayerDitherBG));
5326 }
5327
5328 int view_scr_x = Map.getViewScr() % 16;
5329 int view_scr_y = Map.getViewScr() / 16;
5330 int scr_x = screen % 16;
5331 int scr_y = screen / 16;
5332 int edge_xoff = 0, edge_yoff = 0;
5333 if(showedges)
5334 {
5335 if (scr_x == view_scr_x)
5336 edge_xoff = 16;
5337 else
5338 xoff -= 16;
5339
5340 if (scr_y == view_scr_y)
5341 edge_yoff = 16;
5342 else
5343 yoff -= 16;
5344 }
5345
5346 combotile_add_x = mapscreen_x + xoff;
5347 combotile_add_y = mapscreen_y + yoff;
5348 combotile_mul_x = mapscreen_single_scale;
5349 combotile_mul_y = mapscreen_single_scale;
5350 Map.draw(mapscreenbmp, scr_x == view_scr_x && showedges ? 16 : 0, scr_y == view_scr_y && showedges ? 16 : 0, Flags, Map.getCurrMap(), screen, ActiveLayerHighlight ? CurrentLayer : -1);
5351 combotile_add_x = 0;
5352 combotile_add_y = 0;
5353 combotile_mul_x = 1;
5354 combotile_mul_y = 1;
5355
5356 // TODO: should be better to move this out of draw_screenunit_map_screen.
5357 if (showedges && screen < 128)
5358 {
5359 bool peek_above = scr_y == view_scr_y;
5360 bool peek_below = scr_y == view_scr_y + num_screens_to_draw - 1;
5361 bool peek_left = scr_x == view_scr_x;
5362 bool peek_right = scr_x == view_scr_x + num_screens_to_draw - 1;
5363
5364 int right_col = 272 - (num_screens_to_draw > 1 ? 16 : 0);
5365 int bottom_row = 192 - (num_screens_to_draw > 1 ? 16 : 0);
5366
5367 //not the first row of screens
5368 if (peek_above)
5369 {
5370 if(screen>15 && !NoScreenPreview)
5371 {
5372 Map.drawrow(mapscreenbmp, edge_xoff, 0, Flags, 160, -1, screen-16);
5373 }
5374 else
5375 {
5376 Map.drawstaticrow(mapscreenbmp, edge_xoff, 0);
5377 }
5378 }
5379
5380 //not the last row of screens
5381 if (peek_below)
5382 {
5383 if(screen + 16 < 0x80 && !NoScreenPreview)
5384 {
5385 Map.drawrow(mapscreenbmp, edge_xoff, bottom_row, Flags, 0, -1, screen+16);
5386 }
5387 else
5388 {
5389 Map.drawstaticrow(mapscreenbmp, edge_xoff, bottom_row);
5390 }
5391 }
5392
5393 //not the first column of screens
5394 if (peek_left)
5395 {
5396 if(screen&0x0F && !NoScreenPreview)
5397 {
5398 Map.drawcolumn(mapscreenbmp, 0, edge_yoff, Flags, 15, -1, screen-1);
5399 }
5400 else
5401 {
5402 Map.drawstaticcolumn(mapscreenbmp, 0, edge_yoff);
5403 }
5404 }
5405
5406 //not the last column of screens
5407 if (peek_right)
5408 {
5409 if((screen&0x0F)<15 && !NoScreenPreview)
5410 {
5411 Map.drawcolumn(mapscreenbmp, right_col, edge_yoff, Flags, 0, -1, screen+1);
5412 }
5413 else
5414 {
5415 Map.drawstaticcolumn(mapscreenbmp, right_col, edge_yoff);
5416 }
5417 }
5418
5419 //not the first row or first column of screens
5420 if (peek_above && peek_left)
5421 {
5422 if((screen>15)&&(screen&0x0F) && !NoScreenPreview)
5423 {
5424 Map.drawblock(mapscreenbmp, 0, 0, Flags, 175, -1, screen-17);
5425 }
5426 else
5427 {
5428 Map.drawstaticblock(mapscreenbmp, 0, 0);
5429 }
5430 }
5431
5432 //not the first row or last column of screens
5433 if (peek_above && peek_right)
5434 {
5435 if((screen>15)&&((screen&0x0F)<15) && !NoScreenPreview)
5436 {
5437 Map.drawblock(mapscreenbmp, right_col, 0, Flags, 160, -1, screen-15);
5438 }
5439 else
5440 {
5441 Map.drawstaticblock(mapscreenbmp, right_col, 0);
5442 }
5443 }
5444
5445 //not the last row or first column of screens
5446 if (peek_below && peek_left)
5447 {
5448 if((screen<112)&&(screen&0x0F) && !NoScreenPreview)
5449 {
5450 Map.drawblock(mapscreenbmp, 0, bottom_row, Flags, 15, -1, screen+15);
5451 }
5452 else
5453 {
5454 Map.drawstaticblock(mapscreenbmp, 0, bottom_row);
5455 }
5456 }
5457
5458 //not the last row or last column of screens
5459 if (peek_below && peek_right)
5460 {
5461 if((screen<112)&&((screen&0x0F)<15) && !NoScreenPreview)
5462 {
5463 Map.drawblock(mapscreenbmp, right_col, bottom_row, Flags, 0, -1, screen+17);
5464 }
5465 else
5466 {
5467 Map.drawstaticblock(mapscreenbmp, right_col, bottom_row);
5468 }
5469 }
5470 }
5471
5472 if (ShowSquares && Map.getViewSize() < 4)
5473 {
5474 if(scr->stairx || scr->stairy)
5475 {
5476 int32_t x1 = scr->stairx+edge_xoff;
5477 int32_t y1 = scr->stairy+edge_yoff;
5478 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,vc(14));
5479 }
5480
5481 if(scr->warparrivalx || scr->warparrivaly)
5482 {
5483 int32_t x1 = scr->warparrivalx +edge_xoff;
5484 int32_t y1 = scr->warparrivaly +edge_yoff;
5485 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,vc(10));
5486 }
5487
5488 for(int32_t i=0; i<4; i++) if(scr->warpreturnx[i] || scr->warpreturny[i])
5489 {
5490 int32_t x1 = scr->warpreturnx[i]+edge_xoff;
5491 int32_t y1 = scr->warpreturny[i]+edge_yoff;
5492 int32_t clr = vc(9);
5493
5494 if(FlashWarpSquare==i)
5495 {
5496 if(!FlashWarpClk)
5497 FlashWarpSquare=-1;
5498 else if(!(--FlashWarpClk%3))
5499 clr = vc(15);
5500 }
5501
5502 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,clr);
5503 }
5504 }
5505
5506 if(ShowFFCs)
5507 {
5508 mapscr* ffscr = prv_mode ? Map.get_prvscr() : scr;
5509 int num_ffcs = ffscr->numFFC();
5510 for(int32_t i=num_ffcs-1; i>=0; i--)
5511 {
5512 ffcdata& ff = ffscr->ffcs[i];
5513 if(ff.data !=0 && (ff.layer >= CurrentLayer || (ff.flags&ffc_overlay)))
5514 {
5515 auto x = ff.x+edge_xoff;
5516 auto y = ff.y+edge_yoff;
5517 safe_rect(mapscreenbmp, x+0, y+0, x+ff.txsz*16-1, y+ff.tysz*16-1, vc(12));
5518 }
5519 }
5520 }
5521
5522 if(!(Flags&cDEBUG) && pixeldb==1)
5523 {
5524 for(int32_t j=168; j<176; j++)
5525 {
5526 for(int32_t i=0; i<256; i++)
5527 {
5528 if(((i^j)&1)==0)
5529 {
5530 putpixel(mapscreenbmp,edge_xoff+i,
5531 edge_yoff+j,vc(blackout_color));
5532 }
5533 }
5534 }
5535 }
5536
5537 int w = mapscreenbmp->w * mapscreen_single_scale;
5538 int h = mapscreenbmp->h * mapscreen_single_scale;
5539 stretch_blit(mapscreenbmp, menu1, 0, 0, mapscreenbmp->w, mapscreenbmp->h, mapscreen_x + xoff, mapscreen_y + yoff, w, h);
5540 }
5541
5542 void draw_screenunit(int32_t unit, int32_t flags)
5543 {
5544 FONT* tfont = font;
5545 switch(unit)
5546 {
5547 case rSCRMAP:
5548 {
5549 size_and_pos *mini_sqr = &minimap;
5550 size_and_pos *real_mini_sqr = &real_minimap;
5551
5552 if(zoomed_minimap)
5553 {
5554 mini_sqr = &minimap_zoomed;
5555 real_mini_sqr = &real_minimap_zoomed;
5556 }
5557
5558 auto txt_x = real_mini_sqr->x+2+8*real_mini_sqr->xscale;
5559 auto txt_y = real_mini_sqr->y+2+8*real_mini_sqr->yscale;
5560
5561 rectfill(menu1, mini_sqr->x-1, mini_sqr->y-2,mini_sqr->x+mini_sqr->w-1,mini_sqr->y+mini_sqr->h-1,jwin_pal[jcBOX]);
5562 if(zoomed_minimap)
5563 jwin_draw_frame(menu1, mini_sqr->x-1, mini_sqr->y-2,mini_sqr->w,mini_sqr->h,FR_WIN);
5564 jwin_draw_minimap_frame(menu1,real_mini_sqr->x,real_mini_sqr->y,real_mini_sqr->tw(), real_mini_sqr->th(), real_mini_sqr->xscale, FR_DEEP);
5565
5566 if(Map.getCurrMap()<Map.getMapCount())
5567 {
5568 for(int32_t i=0; i<MAPSCRS; i++)
5569 {
5570 auto& sqr = real_mini_sqr->subsquare(i);
5571
5572 if(Map.Scr(i)->valid&mVALID)
5573 {
5574 // Handled by mmap_draw.
5575 }
5576 else
5577 {
5578 if (InvalidBG == 2)
5579 {
5580 draw_checkerboard(menu1, sqr.x, sqr.y, sqr.w);
5581 }
5582 else if (InvalidBG == 1)
5583 {
5584 for(int32_t dy=0; dy<sqr.h; dy++)
5585 {
5586 for(int32_t dx=0; dx<sqr.w; dx++)
5587 {
5588 menu1->line[dy+sqr.y][dx+sqr.x]=vc((((zc_oldrand()%100)/50)?0:8)+(((zc_oldrand()%100)/50)?0:7));
5589 }
5590 }
5591 }
5592 else
5593 {
5594 int32_t offs = 2*(sqr.w/9);
5595 draw_x(menu1, sqr.x+offs, sqr.y+offs, sqr.x+sqr.w-1-offs, sqr.y+sqr.h-1-offs, vc(15));
5596 }
5597 }
5598 }
5599
5600 int32_t s=Map.getCurrScr();
5601
5602 BITMAP* txtbmp = create_bitmap_ex(8,256,64);
5603 clear_bitmap(txtbmp);
5604 int txtscale = zoomed_minimap ? (is_compact ? 2 : 3) : 1;
5605 font = get_zc_font(font_lfont_l);
5606
5607 int32_t space = text_length(font, "255")+2, spc_s = text_length(font, "S")+2, spc_m = text_length(font, "M")+2;
5608 textprintf_disabled(txtbmp,font,0,0,jwin_pal[jcLIGHT],jwin_pal[jcMEDDARK],"M");
5609 static int map_shortcut_tooltip_id = ttip_register_id();
5610 ttip_install(map_shortcut_tooltip_id, "Prev map: ,\nNext map: .", txt_x, txt_y, 30, 20, txt_x, txt_y - 60);
5611
5612 textprintf_ex(txtbmp,font,spc_m,0,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%-3d",Map.getCurrMap()+1);
5613
5614 textprintf_disabled(txtbmp,font,spc_m+space,0,jwin_pal[jcLIGHT],jwin_pal[jcMEDDARK],"S");
5615 textprintf_ex(txtbmp,font,spc_m+space+spc_s,0,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"0x%02X (%d)",s, s);
5616 masked_stretch_blit(txtbmp, menu1, 0, 0, 256, 64, txt_x, txt_y, 256*txtscale, 64*txtscale);
5617 destroy_bitmap(txtbmp);
5618 }
5619 }
5620 break;
5621 case rMAP:
5622 {
5623 refresh_visible_screens();
5624 mapscreen_single_scale = (double)mapscreen_screenunit_scale / Map.getViewSize();
5625
5626 int num_combos_width = 16 * Map.getViewSize();
5627 int num_combos_height = 11 * Map.getViewSize();
5628
5629 if(CurrentLayer > 0 && !mapscreen_valid_layers[CurrentLayer-1])
5630 CurrentLayer = 0;
5631
5632 for (auto& vis_screen : visible_screens)
5633 {
5634 draw_screenunit_map_screen(vis_screen);
5635 }
5636
5637 if (showxypos_icon)
5638 {
5639 int x0 = showxypos_x + (showedges?16:0);
5640 int y0 = showxypos_y + (showedges?16:0);
5641 int x1 = x0 + showxypos_w - 1;
5642 int y1 = y0 + showxypos_h - 1;
5643 x0 *= mapscreen_single_scale;
5644 y0 *= mapscreen_single_scale;
5645 x1 *= mapscreen_single_scale;
5646 y1 *= mapscreen_single_scale;
5647 x0 += mapscreen_x;
5648 y0 += mapscreen_y;
5649 x1 += mapscreen_x;
5650 y1 += mapscreen_y;
5651
5652 if (showxypos_color == vc(15))
5653 safe_rect(menu1, x0, y0, x1, y1, showxypos_color);
5654 else
5655 rectfill(menu1, x0, y0, x1, y1, showxypos_color);
5656 }
5657
5658 if(showxypos_cursor_icon)
5659 {
5660 int x0 = showxypos_cursor_x + (showedges?16:0);
5661 int y0 = showxypos_cursor_y + (showedges?16:0);
5662 int x1 = x0 + showxypos_w - 1;
5663 int y1 = y0 + showxypos_h - 1;
5664 x0 *= mapscreen_single_scale;
5665 y0 *= mapscreen_single_scale;
5666 x1 *= mapscreen_single_scale;
5667 y1 *= mapscreen_single_scale;
5668 x0 += mapscreen_x;
5669 y0 += mapscreen_y;
5670 x1 += mapscreen_x;
5671 y1 += mapscreen_y;
5672 safe_rect(menu1, x0, y0, x1, y1, showxypos_cursor_color);
5673 }
5674
5675 // Draw dithering over the edge/preview combos.
5676 if(showedges)
5677 {
5678 int tile_size = 16 * mapscreen_single_scale;
5679 int tiles_across = (16 * Map.getViewSize()) + 2;
5680 int bottom_row_y = (Map.getViewSize()*11 + 1) * tile_size;
5681 int right_col_x = (Map.getViewSize()*16 + 1) * tile_size;
5682
5683 //top preview
5684 for(int32_t j=0; j<tile_size; j++)
5685 {
5686 for(int32_t i=0; i<tiles_across * tile_size; i++)
5687 {
5688 if(((i^j)&1)==0)
5689 {
5690 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5691 }
5692 }
5693 }
5694
5695 //bottom preview
5696 for(int32_t j = bottom_row_y; j < bottom_row_y + tile_size; j++)
5697 {
5698 for(int32_t i=0; i<tiles_across * tile_size; i++)
5699 {
5700 if(((i^j)&1)==0)
5701 {
5702 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5703 }
5704 }
5705 }
5706
5707 //left preview
5708 for(int32_t j=tile_size; j<int32_t(192*mapscreen_screenunit_scale); j++)
5709 {
5710 for(int32_t i=0; i<16*mapscreen_single_scale; i++)
5711 {
5712 if(((i^j)&1)==0)
5713 {
5714 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5715 }
5716 }
5717 }
5718
5719 //right preview
5720 for(int32_t j=tile_size; j<int32_t(192*mapscreen_screenunit_scale); j++)
5721 {
5722 for(int32_t i = right_col_x; i < right_col_x + tile_size; i++)
5723 {
5724 if(((i^j)&1)==0)
5725 {
5726 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5727 }
5728 }
5729 }
5730 }
5731
5732 if(!(Flags&cDEBUG) && pixeldb==2)
5733 {
5734 for(int32_t j=int32_t(168*mapscreen_single_scale); j<int32_t(176*mapscreen_single_scale); j++)
5735 {
5736 for(int32_t i=0; i<int32_t(256*mapscreen_single_scale); i++)
5737 {
5738
5739 if(((i^j)&1)==0)
5740 {
5741 putpixel(menu1,int32_t(mapscreen_x+(showedges?(16*mapscreen_single_scale):0)+i),
5742 int32_t(mapscreen_y+(showedges?(16*mapscreen_single_scale):0)+j),vc(blackout_color));
5743 }
5744 }
5745 }
5746 }
5747
5748 // TODO: This should move to `zmap::draw` (and delete the current code there doing a similar thing).
5749 if (Map.isDark(Map.getCurrScr()) && Map.getViewSize() == 1)
5750 {
5751 if((Flags&cNEWDARK) && get_qr(qr_NEW_DARKROOM))
5752 {
5753 BITMAP* tmpDark = create_bitmap_ex(8,16*16,16*11);
5754 BITMAP* tmpDarkTrans = create_bitmap_ex(8,16*16,16*11);
5755 BITMAP* tmpbuf = create_bitmap_ex(8,
5756 mapscreen_single_scale*(256+(showedges?32:0)),
5757 mapscreen_single_scale*(176+(showedges?32:0)));
5758 BITMAP* tmpbuf2 = create_bitmap_ex(8,
5759 mapscreen_single_scale*(256+(showedges?32:0)),
5760 mapscreen_single_scale*(176+(showedges?32:0)));
5761 int32_t darkCol = zinit.darkcol;
5762 switch(darkCol) //special cases
5763 {
5764 case BLACK:
5765 darkCol = vc(0);
5766 break;
5767 case WHITE:
5768 darkCol = vc(15);
5769 break;
5770 }
5771 clear_to_color(tmpDark, darkCol);
5772 clear_to_color(tmpDarkTrans, darkCol);
5773 clear_bitmap(tmpbuf);
5774 clear_bitmap(tmpbuf2);
5775 //Handle torch combos
5776 color_map = &trans_table2;
5777 Map.draw_darkness(tmpDark, tmpDarkTrans);
5778 //
5779 mapscr* tmp = Map.CurrScr();
5780 if(tmp->flags9 & fDARK_DITHER)
5781 {
5782 ditherblit(tmpDark, tmpDark, 0, zinit.dither_type, zinit.dither_arg);
5783 ditherblit(tmpDarkTrans, tmpDarkTrans, 0, zinit.dither_type, zinit.dither_arg);
5784 }
5785
5786 if(mapscreen_single_scale == 1)
5787 {
5788 blit(tmpDark, tmpbuf, 0, 0, (showedges?16:0), (showedges?16:0), 16*16, 16*11);
5789 blit(tmpDarkTrans, tmpbuf2, 0, 0, (showedges?16:0), (showedges?16:0), 16*16, 16*11);
5790 }
5791 else
5792 {
5793 stretch_blit(tmpDark, tmpbuf, 0, 0, 16*16, 16*11,
5794 (showedges?16:0)*mapscreen_single_scale, (showedges?16:0)*mapscreen_single_scale,
5795 (16*16)*mapscreen_single_scale, (16*11)*mapscreen_single_scale);
5796 stretch_blit(tmpDarkTrans, tmpbuf2, 0, 0, 16*16, 16*11,
5797 (showedges?16:0)*mapscreen_single_scale, (showedges?16:0)*mapscreen_single_scale,
5798 (16*16)*mapscreen_single_scale, (16*11)*mapscreen_single_scale);
5799 }
5800
5801 if(tmp->flags9 & fDARK_TRANS)
5802 {
5803 draw_trans_sprite(menu1, tmpbuf, mapscreen_x, mapscreen_y);
5804 }
5805 else
5806 {
5807 masked_blit(tmpbuf,menu1,0,0,mapscreen_x,mapscreen_y,tmpbuf->w,tmpbuf->h);
5808 }
5809 draw_trans_sprite(menu1, tmpbuf2, mapscreen_x, mapscreen_y);
5810 color_map = &trans_table;
5811 //
5812 destroy_bitmap(tmpDark);
5813 destroy_bitmap(tmpDarkTrans);
5814 destroy_bitmap(tmpbuf);
5815 destroy_bitmap(tmpbuf2);
5816 }
5817 else if(!(Flags&cNODARK))
5818 {
5819 for(int32_t j=0; j<80*mapscreen_single_scale; j++)
5820 {
5821 for(int32_t i=0; i<(80*mapscreen_single_scale)-j; i++)
5822 {
5823 if(((i^j)&1)==0)
5824 {
5825 putpixel(menu1,int32_t(mapscreen_x+(showedges?(16*mapscreen_single_scale):0))+i,
5826 int32_t(mapscreen_y+(showedges?(16*mapscreen_single_scale):0)+j),vc(blackout_color));
5827 }
5828 }
5829 }
5830 }
5831 }
5832
5833 double startx=mapscreen_x+(showedges?(16*mapscreen_single_scale):0);
5834 double starty=mapscreen_y+(showedges?(16*mapscreen_single_scale):0);
5835 bool inrect = isinRect(gui_mouse_x(),gui_mouse_y(),startx,starty,(startx+(256*mapscreen_screenunit_scale)-1),(starty+(176*mapscreen_screenunit_scale)-1));
5836
5837 if(!(flags&rNOCURSOR) && ((ComboBrush && !ComboBrushPause)||draw_mode==dm_alias) && inrect)
5838 {
5839 int mgridscale=16*mapscreen_single_scale;
5840 if(allowHideMouse)
5841 {
5842 if(arrowcursor)
5843 {
5844 arrowcursor = false;
5845 MouseSprite::set(ZQM_BLANK);
5846 }
5847 }
5848 else if(!arrowcursor)
5849 {
5850 arrowcursor = true;
5851 MouseSprite::set(ZQM_NORMAL);
5852 }
5853 ComboPosition pos = get_mapscreen_mouse_combo_pos();
5854 int32_t mx = pos.x * 16 * mapscreen_single_scale;
5855 int32_t my = pos.y * 16 * mapscreen_single_scale;
5856
5857 clear_bitmap(brushscreen);
5858 int32_t tempbw=BrushWidth;
5859 int32_t tempbh=BrushHeight;
5860
5861 if(draw_mode==dm_alias)
5862 {
5863 BrushWidth = combo_aliases[combo_apos].width+1;
5864 BrushHeight = combo_aliases[combo_apos].height+1;
5865 }
5866 else if(draw_mode == dm_cpool)
5867 {
5868 BrushWidth = BrushHeight = 1;
5869 combo_pool const& pool = combo_pools[combo_pool_pos];
5870 if(pool.valid())
5871 {
5872 int32_t cid = Combo;
5873 int8_t cset = CSet;
5874 pool.get_w_wrap(cid,cset,cpoolbrush_index/16); //divide to reduce speed
5875 put_combo(brushbmp,0,0,cid,cset,Flags&(cFLAGS|cWALK),0);
5876 }
5877 else clear_bitmap(brushbmp);
5878 }
5879 else if (draw_mode == dm_auto)
5880 {
5881 BrushWidth = BrushHeight = 1;
5882 }
5883
5884 stretch_blit(brushbmp, brushscreen, 0, 0, BrushWidth*16, BrushHeight*16, 0, 0, BrushWidth*mgridscale, BrushHeight*mgridscale);
5885 int float_offx = 0;
5886 int float_offy = 0;
5887
5888 if(FloatBrush)
5889 {
5890 float_offx = -SHADOW_DEPTH*mapscreen_single_scale;
5891 float_offy = -SHADOW_DEPTH*mapscreen_single_scale;
5892
5893 //shadow
5894 for(int x = 0; x < SHADOW_DEPTH*mapscreen_single_scale; ++x)
5895 for(int y = 0; y < (BrushHeight*mgridscale) + (SHADOW_DEPTH*mapscreen_single_scale); ++y)
5896 {
5897 if((((x^y)&1)==1) && y < 12*mgridscale)
5898 putpixel(brushscreen,x+(BrushWidth*mgridscale),y,vc(0));
5899 }
5900
5901 for(int x = 0; x < BrushWidth*mgridscale; ++x)
5902 for(int y = 0; y < SHADOW_DEPTH*mapscreen_single_scale; ++y)
5903 {
5904 if((((x^y)&1)==1) && x<16*mgridscale)
5905 putpixel(brushscreen,x,y+(BrushHeight*mgridscale),vc(0));
5906 }
5907 }
5908
5909 if(draw_mode==dm_alias)
5910 {
5911 combo_alias *combo = &combo_aliases[combo_apos];
5912
5913 if(BrushWidth > 1 && (alias_origin & 1)) //right-align
5914 float_offx -= (BrushWidth - 1) * mgridscale;
5915
5916 if(BrushHeight > 1 && (alias_origin & 2)) //bottom-align
5917 float_offy -= (BrushHeight - 1) * mgridscale;
5918 }
5919
5920 int bx = mapscreen_x + mx + float_offx + (showedges?(16*mapscreen_single_scale):0);
5921 int by = mapscreen_y + my + float_offy + (showedges?(16*mapscreen_single_scale):0);
5922 masked_blit(brushscreen, menu1, 0, 0, bx, by, 16*mgridscale, 11*mgridscale);
5923 BrushWidth=tempbw;
5924 BrushHeight=tempbh;
5925 }
5926 else
5927 {
5928 if(!arrowcursor)
5929 {
5930 MouseSprite::set(ZQM_NORMAL);
5931 arrowcursor = true;
5932 }
5933 }
5934
5935 int startxint = mapscreen_x+(showedges?int(16*mapscreen_single_scale):0);
5936 int startyint = mapscreen_y+(showedges?int(16*mapscreen_single_scale):0);
5937 int endxint = startx + 256*mapscreen_screenunit_scale - 1;
5938 int endyint = starty + 176*mapscreen_screenunit_scale - 1;
5939 set_clip_rect(menu1,startxint,startyint,endxint,endyint);
5940
5941 if(ShowGrid)
5942 {
5943 int w = num_combos_width;
5944 int h = num_combos_height;
5945 double tile_size = 16.0 / Map.getViewSize() * mapscreen_screenunit_scale;
5946
5947 if(showedges)
5948 {
5949 w += 2;
5950 h += 2;
5951 }
5952
5953 for (int x = 1; x < w; x++)
5954 {
5955 vline(menu1, mapscreen_x + x*tile_size, mapscreen_y, mapscreen_y + (h*tile_size)-1, vc(GridColor));
5956 }
5957
5958 for (int y = 1; y < h; y++)
5959 {
5960 hline(menu1, mapscreen_x, mapscreen_y + y*tile_size, mapscreen_x + (w*tile_size)-1, vc(GridColor));
5961 }
5962 }
5963
5964 if(ShowScreenGrid)
5965 {
5966 int w = num_combos_width;
5967 int h = num_combos_height;
5968 double tile_size = 16.0 / Map.getViewSize() * mapscreen_screenunit_scale;
5969 int startx = mapscreen_x + (showedges ? (16 * mapscreen_single_scale) : 0);
5970 int starty = mapscreen_y + (showedges ? (16 * mapscreen_single_scale) : 0);
5971
5972 if(showedges)
5973 {
5974 w += 1;
5975 h += 1;
5976 }
5977
5978 int color = (GridColor+8)%16;
5979
5980 for (int x = 16; x < w; x+=16)
5981 {
5982 vline(menu1, startx + x*tile_size, mapscreen_y, starty + (h*tile_size)-1, vc(color));
5983 }
5984
5985 for (int y = 11; y < h; y+=11)
5986 {
5987 hline(menu1, startx, starty + y*tile_size, startx + (w*tile_size)-1, vc(color));
5988 }
5989 }
5990
5991 // Draw a rect around regions.
5992 if (ShowRegionGrid && Map.getViewSize() > 1)
5993 {
5994 for (const auto& region_description : Map.get_region_descriptions())
5995 {
5996 int sx = region_description.screen % 16;
5997 int sy = region_description.screen / 16;
5998 int sw = region_description.w;
5999 int sh = region_description.h;
6000
6001 int mw = 256 * mapscreen_single_scale;
6002 int mh = 176 * mapscreen_single_scale;
6003 int mx = sx - (Map.getViewScr() % 16);
6004 int my = sy - (Map.getViewScr() / 16);
6005 int x0 = mapscreen_x + (showedges ? (16 * mapscreen_single_scale) : 0) + mx * mw;
6006 int y0 = mapscreen_y + (showedges ? (16 * mapscreen_single_scale) : 0) + my * mh;
6007 rect(menu1, x0+2, y0+2, x0 + mw*sw - 2, y0 + mh*sh - 2, vc(1));
6008 rect(menu1, x0+1, y0+1, x0 + mw*sw - 1, y0 + mh*sh - 1, vc(15));
6009 rect(menu1, x0, y0, x0 + mw*sw, y0 + mh*sh, vc(1));
6010 }
6011 }
6012
6013 // Draw a black-yellow-black rect around the currently selected screen.
6014 if (ShowCurScreenOutline && Map.getViewSize() > 1)
6015 {
6016 int mw = 256 * mapscreen_single_scale;
6017 int mh = 176 * mapscreen_single_scale;
6018 int mx = (Map.getCurrScr() % 16) - (Map.getViewScr() % 16);
6019 int my = (Map.getCurrScr() / 16) - (Map.getViewScr() / 16);
6020 int x0 = mapscreen_x + (showedges ? (16 * mapscreen_single_scale) : 0) + mx * mw;
6021 int y0 = mapscreen_y + (showedges ? (16 * mapscreen_single_scale) : 0) + my * mh;
6022 dotted_rect(menu1, x0+2, y0+2, x0 + mw - 2, y0 + mh - 2, vc(1), vc(0));
6023 rect(menu1, x0+1, y0+1, x0 + mw - 1, y0 + mh - 1, vc(14));
6024 dotted_rect(menu1, x0, y0, x0 + mw, y0 + mh, vc(1), vc(0));
6025 }
6026
6027 clear_clip_rect(menu1);
6028
6029 // Map tabs
6030 font = get_custom_font(CFONT_GUI);
6031
6032 map_page[current_mappage].map=Map.getCurrMap();
6033 map_page[current_mappage].screen=Map.getCurrScr();
6034
6035 for(int32_t btn=0; btn<mappage_count; ++btn)
6036 {
6037 char tbuf[15];
6038 sprintf(tbuf, "%d:%02X", map_page[btn].map+1, map_page[btn].screen);
6039 draw_layer_button(menu1,map_page_bar[btn].x, map_page_bar[btn].y, map_page_bar[btn].w, map_page_bar[btn].h,tbuf,(btn==current_mappage?D_SELECTED:0));
6040 }
6041 }
6042 break;
6043 case rCOMBOS:
6044 {
6045 auto real_h = combolist_window.h;
6046 jwin_draw_frame(menu1,combolist_window.x,combolist_window.y,combolist_window.w,real_h, FR_WIN);
6047 rectfill(menu1,combolist_window.x+2,combolist_window.y+2,combolist_window.x+combolist_window.w-3,combolist_window.y+real_h-3,jwin_pal[jcBOX]);
6048
6049 //Scrollers
6050 for(int32_t c = 0; c < num_combo_cols; ++c)
6051 {
6052 auto& pos = combolistscrollers[c];
6053
6054 { //Scroll up
6055 auto& p = pos.subsquare(0);
6056 jwin_draw_frame(menu1,p.x,p.y,p.w,p.h,FR_ETCHED);
6057
6058 for(int32_t i=0; i<3; i++)
6059 {
6060 hline(menu1, p.x+5-i, p.y+4+i, p.x+5+i, jwin_pal[jcBOXFG]);
6061 }
6062 }
6063
6064 { //Scroll down
6065 auto& p = pos.subsquare(1);
6066 jwin_draw_frame(menu1,p.x,p.y,p.w,p.h,FR_ETCHED);
6067
6068 for(int32_t i=0; i<3; i++)
6069 {
6070 hline(menu1,p.x+5-i,p.y+6-i, p.x+5+i, jwin_pal[jcBOXFG]);
6071 }
6072 }
6073 }
6074
6075 if(draw_mode==dm_alias)
6076 {
6077 if(LinkedScroll)
6078 {
6079 int tmp = current_comboalist;
6080 for(int q = tmp-1; q >= 0; --q)
6081 {
6082 combo_alistpos[q] = combo_alistpos[q+1]-(comboaliaslist[q].w*comboaliaslist[q].h);
6083 if(combo_alistpos[q] < 0)
6084 {
6085 tmp = 0;
6086 combo_alistpos[0] = 0;
6087 break;
6088 }
6089 }
6090 for(int q = tmp+1; q < num_combo_cols; ++q)
6091 combo_alistpos[q] = combo_alistpos[q-1]+(comboaliaslist[q-1].w*comboaliaslist[q-1].h);
6092 for(int q = 0; q < num_combo_cols; ++q)
6093 if(combo_apos >= combo_alistpos[q] && combo_apos < combo_alistpos[q] + (comboaliaslist[q].w*comboaliaslist[q].h))
6094 {
6095 current_comboalist = q;
6096 break;
6097 }
6098 }
6099 for(int32_t c = 0; c < num_combo_cols; ++c)
6100 {
6101 auto& pos = comboaliaslist[c];
6102 rectfill(menu1,pos.x,pos.y,pos.x+(pos.w*pos.xscale)-1,pos.y+(pos.h*pos.yscale)-1,0);
6103 jwin_draw_frame(menu1,pos.x-2,pos.y-2,(pos.w*pos.xscale)+4,(pos.h*pos.yscale)+4,FR_DEEP);
6104 }
6105
6106 auto& prev = comboalias_preview;
6107 jwin_draw_frame(menu1, prev.x-2, prev.y-2, prev.w+4, prev.h+4,FR_DEEP);
6108
6109 BITMAP *prv = create_bitmap_ex(8,64,64);
6110 clear_bitmap(prv);
6111 int32_t scalefactor = 1;
6112
6113 for(int32_t j=0; j<num_combo_cols; ++j)
6114 {
6115 auto per_page = (comboaliaslist[j].w * comboaliaslist[j].h);
6116 if(combo_alistpos[j] + per_page >= MAXCOMBOALIASES)
6117 combo_alistpos[j] = MAXCOMBOALIASES-per_page;
6118 auto& col = comboaliaslist[j];
6119 for(int32_t i=0; i<(comboaliaslist[j].w*comboaliaslist[j].h); i++)
6120 {
6121 draw_combo_alias_thumbnail(menu1, &combo_aliases[combo_alistpos[j]+i],
6122 (i%col.w)*col.xscale+col.x, (i/col.w)*col.yscale+col.y, col.xscale/16);
6123 }
6124
6125 if((combo_aliases[combo_apos].width>7)||(combo_aliases[combo_apos].height>7))
6126 {
6127 scalefactor=4;
6128 }
6129 else if((combo_aliases[combo_apos].width>3)||(combo_aliases[combo_apos].height>3))
6130 {
6131 scalefactor=2;
6132 }
6133
6134
6135 if(j==current_comboalist)
6136 {
6137 stretch_blit(brushbmp, prv, 0,0,scalefactor*64,zc_min(scalefactor*64,176),0,0,64,scalefactor==4?44:64);
6138 blit(prv,menu1,0,0,comboalias_preview.x,comboalias_preview.y,comboalias_preview.w,comboalias_preview.h);
6139
6140 int32_t rect_pos=combo_apos-combo_alistpos[current_comboalist];
6141
6142 if((rect_pos>=0)&&(rect_pos<(combo_alistpos[current_comboalist]+(col.w*col.h))))
6143 {
6144 int selw = col.xscale;
6145 int selh = col.yscale;
6146 int x1 = (rect_pos&(col.w-1))*col.xscale+col.x;
6147 int y1 = (rect_pos/col.w)*col.yscale+col.y;
6148 safe_rect(menu1,x1,y1,x1+selw-1,y1+selh-1,vc(CmbCursorCol),2);
6149 }
6150 }
6151 }
6152
6153 destroy_bitmap(prv);
6154 }
6155 else if(draw_mode==dm_cpool)
6156 {
6157 if(LinkedScroll)
6158 {
6159 int tmp = current_cpoollist;
6160 for(int q = tmp-1; q >= 0; --q)
6161 {
6162 combo_pool_listpos[q] = combo_pool_listpos[q+1]-(comboaliaslist[q].w*comboaliaslist[q].h);
6163 if(combo_pool_listpos[q] < 0)
6164 {
6165 tmp = 0;
6166 combo_pool_listpos[0] = 0;
6167 break;
6168 }
6169 }
6170 for(int q = tmp+1; q < num_combo_cols; ++q)
6171 combo_pool_listpos[q] = combo_pool_listpos[q-1]+(comboaliaslist[q-1].w*comboaliaslist[q-1].h);
6172 for(int q = 0; q < num_combo_cols; ++q)
6173 if(combo_pool_pos >= combo_pool_listpos[q] && combo_pool_pos < combo_pool_listpos[q] + (comboaliaslist[q].w*comboaliaslist[q].h))
6174 {
6175 current_cpoollist = q;
6176 break;
6177 }
6178 }
6179 for(int32_t c = 0; c < num_combo_cols; ++c)
6180 {
6181 auto& pos = comboaliaslist[c];
6182 rectfill(menu1,pos.x,pos.y,pos.x+(pos.w*pos.xscale)-1,pos.y+(pos.h*pos.yscale)-1,0);
6183 jwin_draw_frame(menu1,pos.x-2,pos.y-2,(pos.w*comboaliaslist[c].xscale)+4,(pos.h*comboaliaslist[c].yscale)+4,FR_DEEP);
6184 }
6185
6186 for (int32_t j = 0; j < num_combo_cols; ++j) //the actual panes
6187 {
6188 auto per_page = (comboaliaslist[j].w * comboaliaslist[j].h);
6189 if(combo_pool_listpos[j] + per_page >= MAXCOMBOPOOLS)
6190 combo_pool_listpos[j] = MAXCOMBOPOOLS-per_page;
6191 for(int32_t i=0; i<(comboaliaslist[j].w*comboaliaslist[j].h); i++)
6192 {
6193 int32_t cid=-1; int8_t cs=CSet;
6194 combo_pool const& cp = combo_pools[combo_pool_listpos[j]+i];
6195
6196 auto& list = comboaliaslist[j];
6197 if(cp.get_w(cid,cs,0) && !combobuf[cid].tile)
6198 {
6199 cid = -1; //no tile to draw
6200 }
6201 auto cx = (i%list.w)*list.xscale+list.x;
6202 auto cy = (i/list.w)*list.yscale+list.y;
6203 put_combo(menu1,cx,cy,cid,cs,Flags&(cFLAGS|cWALK),0,list.xscale/16);
6204 }
6205 }
6206 int32_t rect_pos=combo_pool_pos-combo_pool_listpos[current_cpoollist];
6207
6208 if((rect_pos>=0)&&(rect_pos<(combo_pool_listpos[current_cpoollist]+(comboaliaslist[current_cpoollist].w*comboaliaslist[current_cpoollist].h))))
6209 {
6210 int selw = comboaliaslist[current_cpoollist].xscale;
6211 int selh = comboaliaslist[current_cpoollist].yscale;
6212 int x1 = (rect_pos&(comboaliaslist[current_cpoollist].w-1))*comboaliaslist[current_cpoollist].xscale+comboaliaslist[current_cpoollist].x;
6213 int y1 = (rect_pos/comboaliaslist[current_cpoollist].w)*comboaliaslist[current_cpoollist].yscale+comboaliaslist[current_cpoollist].y;
6214 safe_rect(menu1,x1,y1,x1+selw-1,y1+selh-1,vc(CmbCursorCol),2);
6215 }
6216
6217 //Handle Preview
6218 combo_pool const& cpool = combo_pools[combo_pool_pos];
6219
6220 int32_t cid; int8_t cs;
6221 size_t total = weighted_cpool ? cpool.getTotalWeight() : cpool.combos.size();
6222 size_t ind = 0;
6223 size_t indw = combopool_preview.w/16;
6224 size_t indh = combopool_preview.h/16;
6225 size_t rows = total ? vbound(total/indw,1,indh) : 0;
6226 if (is_compact)
6227 rows = vbound(rows, 1, 3);
6228 else
6229 rows = vbound(rows, 1, 4);
6230 size_t real_height = rows*16;
6231
6232 cpool_prev_visible = rows > 0;
6233 if(rows)
6234 {
6235 jwin_draw_frame(menu1,combopool_preview.x-2,combopool_preview.y-2,
6236 combopool_preview.w+4,real_height+4,FR_DEEP);
6237 rectfill(menu1,combopool_preview.x,combopool_preview.y,
6238 combopool_preview.x+combopool_preview.w-1,
6239 combopool_preview.y+real_height-1,vc(0));
6240 draw_text_button(menu1,combopool_prevbtn.x,combopool_prevbtn.y,
6241 combopool_prevbtn.w,combopool_prevbtn.h,
6242 weighted_cpool ? "Weighted" : "Unweighted",vc(1),vc(14),0,true);
6243 if(!is_compact)
6244 textprintf_ex(menu1,font,combopool_prevbtn.x+combopool_prevbtn.w+5,
6245 combopool_prevbtn.y,jwin_pal[jcBOXFG],-1,"Preview");
6246 for(auto y = 0; y < real_height; y += 16)
6247 {
6248 for(auto x = 0; x < combopool_preview.w; x += 16, ++ind)
6249 {
6250 auto nx = combopool_preview.x+x, ny = combopool_preview.y+y;
6251 if(ind < total)
6252 {
6253 cs = CSet;
6254 if(weighted_cpool
6255 ? cpool.get_w(cid,cs,ind)
6256 : cpool.get_ind(cid,cs,ind))
6257 {
6258 put_combo(menu1,nx,ny,cid,cs,Flags&(cFLAGS|cWALK),0);
6259 continue;
6260 }
6261 }
6262 //No combo to display
6263 xout(menu1, nx, ny, nx+15, ny+15, vc(15));
6264 }
6265 }
6266 }
6267 }
6268 else if (draw_mode == dm_auto)
6269 {
6270 if (LinkedScroll)
6271 {
6272 int tmp = current_cautolist;
6273 for (int q = tmp - 1; q >= 0; --q)
6274 {
6275 combo_auto_listpos[q] = combo_auto_listpos[q + 1] - (comboaliaslist[q].w * comboaliaslist[q].h);
6276 if (combo_auto_listpos[q] < 0)
6277 {
6278 tmp = 0;
6279 combo_auto_listpos[0] = 0;
6280 break;
6281 }
6282 }
6283 for (int q = tmp + 1; q < num_combo_cols; ++q)
6284 combo_auto_listpos[q] = combo_auto_listpos[q - 1] + (comboaliaslist[q - 1].w * comboaliaslist[q - 1].h);
6285 for (int q = 0; q < num_combo_cols; ++q)
6286 if (combo_auto_pos >= combo_auto_listpos[q] && combo_auto_pos < combo_auto_listpos[q] + (comboaliaslist[q].w * comboaliaslist[q].h))
6287 {
6288 current_cautolist = q;
6289 break;
6290 }
6291 }
6292 for (int32_t c = 0; c < num_combo_cols; ++c)
6293 {
6294 auto& pos = comboaliaslist[c];
6295 rectfill(menu1, pos.x, pos.y, pos.x + (pos.w * pos.xscale) - 1, pos.y + (pos.h * pos.yscale) - 1, 0);
6296 jwin_draw_frame(menu1, pos.x - 2, pos.y - 2, (pos.w * comboaliaslist[c].xscale) + 4, (pos.h * comboaliaslist[c].yscale) + 4, FR_DEEP);
6297 }
6298
6299 for (int32_t j = 0; j < num_combo_cols; ++j) //the actual panes
6300 {
6301 auto per_page = (comboaliaslist[j].w * comboaliaslist[j].h);
6302 if(combo_auto_listpos[j] + per_page >= MAXAUTOCOMBOS)
6303 combo_auto_listpos[j] = MAXAUTOCOMBOS-per_page;
6304 for (int32_t i = 0; i < (comboaliaslist[j].w * comboaliaslist[j].h); i++)
6305 {
6306 int32_t cid = -1; int8_t cs = CSet;
6307 combo_auto const& ca = combo_autos[combo_auto_listpos[j] + i];
6308
6309 auto& list = comboaliaslist[j];
6310 cid = ca.getDisplay();
6311 if (cid == 0)
6312 cid = -1;
6313 auto cx = (i % list.w) * list.xscale + list.x;
6314 auto cy = (i / list.w) * list.yscale + list.y;
6315 put_combo(menu1, cx, cy, cid, cs, Flags & (cFLAGS | cWALK), 0, list.xscale / 16);
6316 put_autocombo_engravings(menu1, ca, combo_auto_listpos[j] + i == combo_auto_pos, cx, cy, list.xscale / 16);
6317 }
6318 }
6319 int32_t rect_pos = combo_auto_pos - combo_auto_listpos[current_cautolist];
6320
6321 if ((rect_pos >= 0) && (rect_pos < (combo_auto_listpos[current_cautolist] + (comboaliaslist[current_cautolist].w * comboaliaslist[current_cautolist].h))))
6322 {
6323 int selw = comboaliaslist[current_cautolist].xscale;
6324 int selh = comboaliaslist[current_cautolist].yscale;
6325 int x1 = (rect_pos & (comboaliaslist[current_cautolist].w - 1)) * comboaliaslist[current_cautolist].xscale + comboaliaslist[current_cautolist].x;
6326 int y1 = (rect_pos / comboaliaslist[current_cautolist].w) * comboaliaslist[current_cautolist].yscale + comboaliaslist[current_cautolist].y;
6327 safe_rect(menu1, x1, y1, x1 + selw - 1, y1 + selh - 1, vc(CmbCursorCol), 2);
6328
6329 combo_auto const& ca = combo_autos[combo_auto_pos];
6330 put_autocombo_engravings(menu1, ca, true, x1, y1, selw / 16);
6331 }
6332 }
6333 else
6334 {
6335 if(LinkedScroll)
6336 {
6337 int tmp = current_combolist;
6338 for(int q = tmp-1; q >= 0; --q)
6339 {
6340 First[q] = First[q+1]-(combolist[q].w*combolist[q].h);
6341 if(First[q] < 0)
6342 {
6343 tmp = 0;
6344 First[0] = 0;
6345 break;
6346 }
6347 }
6348 for(int q = tmp+1; q < num_combo_cols; ++q)
6349 First[q] = First[q-1]+(combolist[q-1].w*combolist[q-1].h);
6350 for(int q = 0; q < num_combo_cols; ++q)
6351 if(Combo >= First[q] && Combo < First[q] + (combolist[q].w*combolist[q].h))
6352 {
6353 current_combolist = q;
6354 break;
6355 }
6356 }
6357 for(int32_t c = 0; c < num_combo_cols; ++c)
6358 {
6359 auto& pos = combolist[c];
6360 rectfill(menu1,pos.x,pos.y,pos.x+(pos.w*pos.xscale)-1,pos.y+(pos.h*pos.yscale)-1,0);
6361 jwin_draw_frame(menu1,pos.x-2,pos.y-2,(pos.w*pos.xscale)+4,(pos.h*pos.yscale)+4,FR_DEEP);
6362 }
6363
6364 int32_t drawmap, drawscr;
6365 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
6366 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
6367
6368 for(int32_t j=0; j<num_combo_cols; ++j)
6369 {
6370 auto per_page = (combolist[j].w * combolist[j].h);
6371 if(First[j] + per_page >= MAXCOMBOS)
6372 First[j] = MAXCOMBOS-per_page;
6373 for(int32_t i=0; i<(combolist[j].w*combolist[j].h); i++)
6374 {
6375 put_combo(menu1,(i%combolist[j].w)*combolist[j].xscale+combolist[j].x,
6376 (i/combolist[j].w)*combolist[j].yscale+combolist[j].y,
6377 i+First[j],CSet,Flags&(cFLAGS|cWALK),0,combolist[j].xscale/16);
6378 }
6379 }
6380
6381 int32_t rect_pos=Combo-First[current_combolist];
6382
6383 if((rect_pos>=0)&&(rect_pos<(combo_pool_listpos[current_combolist]+(combolist[current_combolist].w*combolist[current_combolist].h))))
6384 {
6385 int selw = (AutoBrush?BrushWidth:1)*combolist[current_combolist].xscale;
6386 int selh = (AutoBrush?BrushHeight:1)*combolist[current_combolist].yscale;
6387 int x1 = (rect_pos&(combolist[current_combolist].w-1))*combolist[current_combolist].xscale+combolist[current_combolist].x;
6388 int y1 = (rect_pos/combolist[current_combolist].w)*combolist[current_combolist].yscale+combolist[current_combolist].y;
6389 safe_rect(menu1,x1,y1,x1+selw-1,y1+selh-1,vc(CmbCursorCol),2);
6390 }
6391 }
6392 }
6393 break;
6394 case rCOMBO:
6395 {
6396 int32_t drawmap, drawscr;
6397 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
6398 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
6399
6400 // Combo preview
6401 int32_t cid = Combo; int8_t cs = CSet;
6402 if(draw_mode == dm_alias)
6403 {
6404 cid = combo_aliases[combo_apos].combos[0];
6405 cs = wrap(combo_aliases[combo_apos].csets[0]+alias_cset_mod, 0, 13);
6406 }
6407 else if(draw_mode == dm_cpool)
6408 {
6409 combo_pool const& cpool = combo_pools[combo_pool_pos];
6410 cid = 0;
6411 cpool.get_w(cid,cs,0);
6412 }
6413 else if (draw_mode == dm_auto)
6414 {
6415 combo_auto const& cauto = combo_autos[combo_auto_pos];
6416 cid = cauto.getDisplay();
6417 }
6418 static BITMAP *combo_preview_bmp=create_bitmap_ex(8,32,32);
6419 static BITMAP *cycle_preview_bmp=create_bitmap_ex(8,32,32);
6420 // Combo
6421 put_combo(combo_preview_bmp,0,0,cid,cs,Flags&(cFLAGS|cWALK),0);
6422 jwin_draw_frame(menu1,combo_preview.x-2,combo_preview.y-2,combo_preview.w+4,combo_preview.h+4, FR_DEEP);
6423 stretch_blit(combo_preview_bmp, menu1, 0, 0, 16, 16, combo_preview.x, combo_preview.y, combo_preview.w, combo_preview.h);
6424
6425 comboprev_buf[0] = 0;
6426 comboprev_buf2[0] = 0;
6427 if(draw_mode == dm_cpool)
6428 {
6429 sprintf(comboprev_buf,"Pool: %d\nCSet: %d",combo_pool_pos,CSet);
6430 int x = combo_preview_text1.x+(combo_preview_text1.w*combo_preview_text1.xscale);
6431 textbox_out(menu1,txfont,x,combo_preview_text1.y,jwin_pal[jcBOXFG],jwin_pal[jcBOX],comboprev_buf,2,&combo_preview_text1);
6432 }
6433 else if (draw_mode == dm_auto)
6434 {
6435 GUI::ListData ac_types = GUI::ZCListData::autocombotypes();
6436 std::string type_name = ac_types.findText(combo_autos[combo_auto_pos].getType());
6437 if (is_compact)
6438 sprintf(comboprev_buf, "AC: %d CS: %d\n%s", combo_auto_pos, CSet, type_name.c_str());
6439 else
6440 sprintf(comboprev_buf, "Auto: %d CSet: %d\n%s\nEntries: %d", combo_auto_pos, CSet, type_name.c_str(), int32_t(combo_autos[combo_auto_pos].combos.size()));
6441 int x = combo_preview_text1.x + (combo_preview_text1.w * combo_preview_text1.xscale);
6442 textbox_out(menu1, txfont, x, combo_preview_text1.y, jwin_pal[jcBOXFG], jwin_pal[jcBOX], comboprev_buf, 2, &combo_preview_text1);
6443 }
6444 else if(draw_mode != dm_alias)
6445 {
6446 int x = combo_preview_text1.x+(combo_preview_text1.w*combo_preview_text1.xscale);
6447
6448 char shortbuf[512];
6449 char buf[256];
6450 strcpy(buf,combo_class_buf[combobuf[Combo].type].name);
6451 sprintf(comboprev_buf,"Combo: %d\nCSet: %d\n%s",Combo,CSet,buf);
6452 int ind = strlen(buf)-1;
6453 int x2 = x;
6454 if(x2 - text_length(txfont, buf) <= combolist_window.x)
6455 {
6456 auto dotlen = text_length(txfont, "..");
6457 x2 -= dotlen;
6458 while(x2 - text_length(txfont, buf) <= combolist_window.x)
6459 {
6460 if(ind < 0) break;
6461 buf[ind--] = '\0';
6462 }
6463 while(ind >= 0 && buf[ind] == ' ')
6464 buf[ind--] = 0; //trim spaces
6465 strcat(buf, "..");
6466 }
6467
6468 if(is_compact)
6469 {
6470 char b2[256];
6471 sprintf(b2, "Combo %d CS %d", Combo, CSet);
6472 if(x-text_length(txfont, b2) <= combolist_window.x)
6473 sprintf(b2, "Cmb %d CS %d", Combo, CSet);
6474 sprintf(shortbuf,"%s\n%s",b2,buf);
6475 }
6476 else sprintf(shortbuf,"Combo: %d\nCSet: %d\n%s",Combo,CSet,buf);
6477 textbox_out(menu1,txfont,x,combo_preview_text1.y,jwin_pal[jcBOXFG],jwin_pal[jcBOX],shortbuf,2,&combo_preview_text1);
6478 }
6479
6480 // Cycle
6481 if(!is_compact)
6482 {
6483 int32_t NextCombo = combobuf[Combo].nextcombo;
6484 int32_t NextCSet = combobuf[Combo].nextcset;
6485 if(combobuf[Combo].animflags & AF_CYCLEUNDERCOMBO)
6486 {
6487 mapscr* scr = Map.CurrScr();
6488 NextCombo = scr->undercombo;
6489 NextCSet = scr->undercset;
6490 }
6491 if(combobuf[Combo].animflags & AF_CYCLENOCSET)
6492 NextCSet = CSet;
6493 bool normal_dm = draw_mode != dm_alias && draw_mode != dm_cpool && draw_mode != dm_auto;
6494 jwin_draw_frame(menu1,combo_preview2.x-2,combo_preview2.y-2,combo_preview2.w+4,combo_preview2.h+4, FR_DEEP);
6495 if(NextCombo>0 && normal_dm)
6496 {
6497 put_combo(cycle_preview_bmp,0,0,NextCombo,NextCSet,Flags&(cFLAGS|cWALK),0);
6498
6499 if(Flags&cWALK) put_walkflags(cycle_preview_bmp,0,0,NextCombo,0);
6500
6501 if(Flags&cFLAGS) put_flags(cycle_preview_bmp,0,0,NextCombo,0,cFLAGS,0);
6502
6503 stretch_blit(cycle_preview_bmp, menu1, 0, 0, 16, 16, combo_preview2.x, combo_preview2.y, combo_preview2.w, combo_preview2.h);
6504 }
6505 else
6506 {
6507 if (InvalidBG == 2)
6508 {
6509 draw_checkerboard(menu1, combo_preview2.x, combo_preview2.y, 32);
6510 }
6511 else if(InvalidBG == 1)
6512 {
6513 for(int32_t dy=0; dy<combo_preview2.w; dy++)
6514 {
6515 for(int32_t dx=0; dx<combo_preview2.w; dx++)
6516 {
6517 menu1->line[dy+combo_preview2.y][dx+combo_preview2.x]=vc((((zc_oldrand()%100)/50)?0:8)+(((zc_oldrand()%100)/50)?0:7));
6518 }
6519 }
6520 }
6521 else
6522 {
6523 rectfill(menu1, combo_preview2.x,combo_preview2.y, combo_preview2.x+32,combo_preview2.y+combo_preview2.h,vc(0));
6524 safe_rect(menu1, combo_preview2.x,combo_preview2.y, combo_preview2.x+32,combo_preview2.y+combo_preview2.h,vc(15));
6525 line(menu1, combo_preview2.x,combo_preview2.y, combo_preview2.x+32,combo_preview2.y+combo_preview2.h,vc(15));
6526 line(menu1, combo_preview2.x,combo_preview2.y+combo_preview2.h, combo_preview2.x+32,combo_preview2.y,vc(15));
6527 }
6528 }
6529
6530 if(normal_dm)
6531 {
6532 char shortbuf[512];
6533 char buf[256];
6534 strcpy(buf,combo_class_buf[combobuf[NextCombo].type].name);
6535 sprintf(comboprev_buf2, "Cycle: %d\nCSet: %d\n%s", NextCombo, NextCSet, buf);
6536 int ind = strlen(buf)-1;
6537 int x2 = combo_preview_text2.x;
6538 if(x2 + text_length(txfont, buf) > zq_screen_w-2)
6539 {
6540 auto dotlen = text_length(txfont, "..");
6541 x2 += dotlen;
6542 while(x2 + text_length(txfont, buf) > zq_screen_w-2)
6543 {
6544 if(ind < 0) break;
6545 buf[ind--] = '\0';
6546 }
6547 while(ind >= 0 && buf[ind] == ' ')
6548 buf[ind--] = 0; //trim spaces
6549 strcat(buf, "..");
6550 }
6551
6552 sprintf(shortbuf, "Cycle: %d\nCSet: %d\n%s", NextCombo, NextCSet, buf);
6553 textbox_out(menu1,txfont,combo_preview_text2.x,combo_preview_text2.y,jwin_pal[jcBOXFG],jwin_pal[jcBOX],shortbuf,0,&combo_preview_text2);
6554 }
6555 }
6556
6557 font = get_zc_font(font_lfont_l);
6558 bool merged = is_compact ? compact_merged_combopane : large_merged_combopane;
6559 draw_text_button(menu1,combo_merge_btn.x,combo_merge_btn.y,combo_merge_btn.w,combo_merge_btn.h,merged ? "<|>" : ">|<",vc(1),vc(14),0,true);
6560 }
6561 break;
6562 case rFAVORITES:
6563 {
6564 font = get_zc_font(font_lfont_l);
6565
6566 jwin_draw_frame(menu1,favorites_window.x,favorites_window.y,favorites_window.w,favorites_window.h, FR_WIN);
6567 rectfill(menu1,favorites_window.x+2,favorites_window.y+2,favorites_window.x+favorites_window.w-3,favorites_window.y+favorites_window.h-3,jwin_pal[jcBOX]);
6568 jwin_draw_frame(menu1,favorites_list.x-2,favorites_list.y-2,(favorites_list.w*favorites_list.xscale)+4,(favorites_list.h*favorites_list.yscale)+4, FR_DEEP);
6569 rectfill(menu1,favorites_list.x,favorites_list.y,favorites_list.x+(favorites_list.w*favorites_list.xscale)-1,favorites_list.y+(favorites_list.h*favorites_list.yscale)-1,jwin_pal[jcBOXFG]);
6570
6571 textprintf_ex(menu1,get_zc_font(font_lfont_l),favorites_list.x-2,favorites_list.y-15,jwin_pal[jcBOXFG],-1,is_compact ? "Favorites" : "Favorite Combos");
6572 BITMAP* subb = create_bitmap_ex(8,16,16);
6573
6574 for(int32_t col=0; col<favorites_list.w; ++col)
6575 {
6576 for(int32_t row=0; row<favorites_list.h; ++row)
6577 {
6578 auto i = (row*FAVORITECOMBO_PER_ROW)+col+FAVORITECOMBO_PER_PAGE*FavoriteComboPage;
6579 auto& sqr = favorites_list.subsquare(col,row);
6580 if(i >= MAXFAVORITECOMBOS || favorite_combos[i]==-1)
6581 {
6582 if (InvalidBG == 2)
6583 {
6584 draw_checkerboard(menu1, sqr.x, sqr.y, sqr.w);
6585 }
6586 else if(InvalidBG == 1)
6587 {
6588 for(int32_t dy=0; dy<sqr.h; dy++)
6589 {
6590 for(int32_t dx=0; dx<sqr.w; dx++)
6591 {
6592 menu1->line[sqr.y+dy][sqr.x+dx]=vc((((zc_oldrand()%100)/50)?0:8)+(((zc_oldrand()%100)/50)?0:7));
6593 }
6594 }
6595 }
6596 else
6597 {
6598 xout(menu1, sqr.x, sqr.y, sqr.x+sqr.w-1, sqr.y+sqr.h-1, vc(15), vc(0));
6599 }
6600 }
6601 else
6602 {
6603 clear_bitmap(subb);
6604 bool repos = combotile_override_x < 0 && combotile_override_y < 0;
6605
6606 switch(favorite_combo_modes[i])
6607 {
6608 case dm_alias:
6609 draw_combo_alias_thumbnail(subb, &combo_aliases[favorite_combos[i]], 0, 0, 1);
6610 if (ShowFavoriteComboModes)
6611 put_engraving(subb, 0, 0, 0x3E, 1);
6612 break;
6613 case dm_cpool:
6614 {
6615 int32_t cid = -1; int8_t cs = CSet;
6616 combo_pool const& cp = combo_pools[favorite_combos[i]];
6617
6618 if (cp.get_w(cid, cs, 0) && !combobuf[cid].tile)
6619 cid = -1; //no tile to draw
6620 put_combo(subb, 0, 0, cid, cs, 0, 0);
6621 if (ShowFavoriteComboModes)
6622 put_engraving(subb, 0, 0, 0x3D, 1);
6623 break;
6624 }
6625 case dm_auto:
6626 {
6627 int32_t cid = -1; int8_t cs = CSet;
6628 combo_auto const& ca = combo_autos[favorite_combos[i]];
6629
6630 cid = ca.getDisplay();
6631 if (cid == 0)
6632 cid = -1;
6633 put_combo(subb, 0, 0, cid, cs, 0, 0);
6634 if (ShowFavoriteComboModes)
6635 put_engraving(subb, 0, 0, 0x3C, 1);
6636 break;
6637 }
6638 default:
6639 if (repos)
6640 {
6641 combotile_override_x = sqr.x + (sqr.w - 16) / 2;
6642 combotile_override_y = sqr.y + (sqr.h - 16) / 2;
6643 }
6644 put_combo(subb, 0, 0, favorite_combos[i], CSet, Flags & (cFLAGS | cWALK), 0);
6645 if (repos) combotile_override_x = combotile_override_y = -1;
6646 }
6647 stretch_blit(subb, menu1, 0, 0, 16, 16, sqr.x, sqr.y, sqr.w, sqr.h);
6648 }
6649 }
6650 }
6651
6652 destroy_bitmap(subb);
6653
6654 bool zoomed = is_compact ? compact_zoomed_fav : large_zoomed_fav;
6655 if(!is_compact)
6656 textprintf_right_ex(menu1, get_zc_font(font_lfont_l), favorites_pgleft.x - 2, favorites_pgleft.y, jwin_pal[jcBOXFG], -1, "%d/9", FavoriteComboPage + 1);
6657
6658 draw_text_button(menu1, favorites_pgleft.x, favorites_pgleft.y, favorites_pgleft.w, favorites_pgleft.h, is_compact ? "<" : "<-", vc(1), vc(14), 0, true);
6659 draw_text_button(menu1, favorites_pgright.x, favorites_pgright.y, favorites_pgright.w, favorites_pgright.h, is_compact ? ">" : "->", vc(1), vc(14), 0, true);
6660 draw_text_button(menu1,favorites_zoombtn.x,favorites_zoombtn.y,favorites_zoombtn.w,favorites_zoombtn.h,zoomed ? "-" : "+",vc(1),vc(14),0,true);
6661 draw_text_button(menu1,favorites_x.x,favorites_x.y,favorites_x.w,favorites_x.h,"X",vc(1),vc(14),0,true);
6662 draw_text_button(menu1,favorites_infobtn.x,favorites_infobtn.y,favorites_infobtn.w,favorites_infobtn.h,"?",vc(1),vc(14),0,true);
6663 }
6664 break;
6665 case rCOMMANDS:
6666 {
6667 jwin_draw_frame(menu1,commands_window.x,commands_window.y,commands_window.w,commands_window.h, FR_WIN);
6668 rectfill(menu1,commands_window.x+2,commands_window.y+2,commands_window.x+commands_window.w-3,commands_window.y+commands_window.h-3,jwin_pal[jcBOX]);
6669 jwin_draw_frame(menu1,commands_list.x-2,commands_list.y-2,(commands_list.w*commands_list.xscale)+4,(commands_list.h*commands_list.yscale)+4, FR_DEEP);
6670 rectfill(menu1,commands_list.x,commands_list.y,commands_list.x+(commands_list.w*commands_list.xscale)-1,commands_list.y+(commands_list.h*commands_list.yscale)-1,jwin_pal[jcBOXFG]);
6671 font=get_custom_font(CFONT_FAVCMD);
6672
6673 for(int32_t cmd=0; cmd<(commands_list.w*commands_list.h); ++cmd)
6674 {
6675 uint hkey = favorite_commands[cmd];
6676 draw_layer_button(menu1,
6677 (cmd%commands_list.w)*commands_list.xscale+commands_list.x,
6678 (cmd/commands_list.w)*commands_list.yscale+commands_list.y,
6679 commands_list.xscale,
6680 commands_list.yscale,
6681 get_hotkey_name(hkey),
6682 (selected_hotkey(hkey)?D_SELECTED:0) | (disabled_hotkey(hkey)?D_DISABLED:0));
6683 }
6684
6685 font = get_zc_font(font_lfont_l);
6686 if(commands_txt.x > 0)
6687 {
6688 gui_textout_ln(menu1, get_zc_font(font_lfont_l), (ucc*)"Favorite Commands", commands_txt.x, commands_txt.y, jwin_pal[jcBOXFG], -1, 0);
6689 }
6690
6691 bool zoomed = is_compact ? compact_zoomed_cmd : large_zoomed_cmd;
6692 draw_text_button(menu1,commands_zoombtn.x,commands_zoombtn.y,commands_zoombtn.w,commands_zoombtn.h,zoomed ? "-" : "+",vc(1),vc(14),0,true);
6693 draw_text_button(menu1,commands_x.x,commands_x.y,commands_x.w,commands_x.h,"X",vc(1),vc(14),0,true);
6694 draw_text_button(menu1,commands_infobtn.x,commands_infobtn.y,commands_infobtn.w,commands_infobtn.h,"?",vc(1),vc(14),0,true);
6695 }
6696 break;
6697 }
6698 font = tfont;
6699 }
6700
6701 bool pause_refresh = true;
6702 bool is_refreshing = false;
6703 11 void refresh(int32_t flags, bool update)
6704 {
6705
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(pause_refresh) return;
6706 static bool refreshing = false;
6707
6708 int num_screens_to_draw = Map.getViewSize();
6709
6710 bool earlyret = refreshing;
6711 is_refreshing = refreshing = true;
6712 //^ These prevent recursive calls from updating the screen early
6713
6714 bool zoom_delay = (zoomed_minimap && flags != rSCRMAP);
6715 if(zoom_delay)
6716 flags &= ~rSCRMAP;
6717
6718 if(flags&rCLEAR)
6719 {
6720 //magic pink = 0xED
6721 //system black = vc(0)
6722 //Clear a4 menu
6723 clear_to_color(menu1,jwin_pal[jcBOX]);
6724
6725 //Clears should refresh everything!
6726 flags |= rALL;
6727 }
6728
6729 if(flags&rSCRMAP)
6730 draw_screenunit(rSCRMAP,flags);
6731
6732 if(flags&rMAP)
6733 draw_screenunit(rMAP,flags);
6734
6735 if((flags&rCOMBOS) || (draw_mode == dm_cpool && (flags&rFAVORITES)))
6736 draw_screenunit(rCOMBOS,flags);
6737
6738 if(flags&(rCOMBO|rCOMBOS))
6739 draw_screenunit(rCOMBO,flags);
6740
6741 if(flags&rMENU)
6742 drawpanel();
6743
6744 if(flags&rFAVORITES)
6745 draw_screenunit(rFAVORITES,flags);
6746
6747 if(flags&rCOMMANDS)
6748 draw_screenunit(rCOMMANDS,flags);
6749
6750 FONT* tfont = font;
6751 font = get_custom_font(CFONT_GUI);
6752 jwin_draw_frame(menu1,layer_panel.x,layer_panel.y,layer_panel.w,layer_panel.h,FR_DEEP);
6753 rectfill(menu1,layer_panel.x,layer_panel.y,layer_panel.x+layer_panel.w-1,layer_panel.y+layer_panel.h-1,jwin_pal[jcBOX]);
6754
6755 for(int32_t i=0; i<=6; ++i)
6756 {
6757 char tbuf[15];
6758
6759 if (i>0 && mapscreen_valid_layers[i - 1] && num_screens_to_draw == 1)
6760 {
6761 if(is_compact)
6762 sprintf(tbuf, "%s%d %d:%02X", (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"", i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
6763 else sprintf(tbuf, "%s%d (%d:%02X)", (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"", i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
6764 }
6765 else
6766 {
6767 sprintf(tbuf, "%s%d", (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"", i);
6768 }
6769
6770 int32_t spacing_offs = is_compact ? 2 : 10;
6771 int32_t rx = (i * (layerpanel_buttonwidth+spacing_offs+layerpanel_checkbox_wid)) + layer_panel.x+(is_compact?2:6);
6772 int32_t ry = layer_panel.y;
6773 auto cbyofs = (layerpanel_buttonheight-layerpanel_checkbox_hei)/2;
6774 draw_layer_button(menu1, rx, ry, layerpanel_buttonwidth, layerpanel_buttonheight, tbuf, CurrentLayer==i? D_SELECTED : ( i > 0 && !mapscreen_valid_layers[i-1]) ? D_DISABLED : 0);
6775 draw_checkbox(menu1,rx+layerpanel_buttonwidth+1,ry+cbyofs,layerpanel_checkbox_wid,layerpanel_checkbox_hei,LayerMaskInt[i]!=0);
6776 }
6777
6778 font=tfont;
6779
6780 // } //if(true)
6781 if(zq_showpal)
6782 {
6783 for(int32_t i=0; i<256; i++)
6784 {
6785 rectfill(menu1,((i&15)<<2)+256,((i>>4)<<2)+176,((i&15)<<2)+259,((i>>4)<<2)+179,i);
6786 }
6787 }
6788 { //Show top-left info
6789 size_t maxwid = (mapscreen_screenunit_scale*mapscreenbmp->w)-1;
6790 size_t maxhei = (mapscreen_screenunit_scale*mapscreenbmp->w);
6791 set_clip_rect(menu1,mapscreen_x,mapscreen_y,mapscreen_x+maxwid-1,mapscreen_y+maxhei-1);
6792 FONT* showfont = get_custom_font(CFONT_INFO);
6793 int showfont_h = text_height(showfont);
6794 int32_t ypos = mapscreen_y;
6795 if(prv_mode)
6796 {
6797 textout_shadowed_ex(menu1,showfont,"Preview Mode",0,ypos,vc(15),vc(0),infobg?vc(0):-1);
6798 ypos += showfont_h+1;
6799 if(prv_twon)
6800 {
6801 textprintf_shadowed_ex(menu1,showfont,0,ypos,vc(15),vc(0),infobg?vc(0):-1,"T Warp=%d tics", Map.get_prvtime());
6802 ypos += showfont_h+1;
6803 }
6804 }
6805 if(ShowFPS)
6806 {
6807 textprintf_shadowed_ex(menu1,showfont,0,ypos,vc(15),vc(0),infobg?vc(0):-1,"FPS: %3d",lastfps);
6808 ypos += showfont_h+1;
6809 }
6810
6811 if(ShowFFScripts && !prv_mode)
6812 {
6813 word num_ffcs = Map.CurrScr()->numFFC();
6814 for(word i=0; i< num_ffcs; i++)
6815 {
6816 if(ypos+showfont_h-1 > map_page_bar[0].y)
6817 break;
6818 if(Map.CurrScr()->ffcs[i].script && Map.CurrScr()->ffcs[i].data)
6819 {
6820 textout_shadowed_ex(menu1, showfont, ffcmap[Map.CurrScr()->ffcs[i].script-1].scriptname.substr(0,300).c_str(),0,ypos,vc(showxypos_ffc==i ? 14 : 15),vc(0),infobg?vc(0):-1);
6821 ypos+=showfont_h+1;
6822 }
6823 }
6824 }
6825 clear_clip_rect(menu1);
6826 if(prv_mode)
6827 do_previewtext();
6828 }
6829 // Show Errors & Details
6830 //This includes the presence of: Screen State Carryover, Timed Warp, Maze Path, the 'Sideview Gravity', 'Invisible Hero',
6831 //'Save Screen', 'Continue Here' and 'Treat As..' Screen Flags,
6832 // the String, every Room Type and Catch All, and all four Tile and Side Warps.
6833 if(!prv_mode && ShowInfo)
6834 {
6835 int32_t i=0;
6836 char buf[2048];
6837
6838 // Start with general information
6839 if(Map.CurrScr()->flags3&fINVISHERO)
6840 {
6841 sprintf(buf,"Invisible Hero");
6842 show_screen_error(buf,i++,vc(15));
6843 }
6844
6845 if(Map.getLayerTargetMap() > 0)
6846 {
6847 Map.setlayertarget(); //Now the text does not carry over when changing maps, but shifting back, it does not **re-appear** until you change screens.
6848 //It was also required to set some updates in onDecMap and onIncMap. #
6849 //This fixes Screen Info not displaying properly when changing maps. -Z
6850 //Needed to refresh the screen info. -Z ( 26th March, 2019 )
6851 int32_t m = Map.getLayerTargetMultiple();
6852 sprintf(buf,"Used as a layer by screen %d:%02X",Map.getLayerTargetMap(),Map.getLayerTargetScr());
6853 char buf2[24];
6854
6855 if(m>0)
6856 {
6857 sprintf(buf2," and %d other%s",m,m>1?"s":"");
6858 strcat(buf,buf2);
6859 }
6860
6861 show_screen_error(buf,i++,vc(15));
6862 }
6863
6864 if(Map.CurrScr()->nextmap)
6865 {
6866 sprintf(buf,"Screen State carries over to %d:%02X",Map.CurrScr()->nextmap,Map.CurrScr()->nextscr);
6867 show_screen_error(buf,i++,vc(15));
6868 }
6869
6870 if(Map.CurrScr()->timedwarptics)
6871 {
6872 sprintf(buf,"%s%sTimed Warp: %s",(Map.CurrScr()->flags4&fTIMEDDIRECT)?"Direct ":"",(Map.CurrScr()->flags5&fRANDOMTIMEDWARP)?"Random ":"",ticksstr(Map.CurrScr()->timedwarptics));
6873 show_screen_error(buf,i++,vc(15));
6874 }
6875
6876 if(Map.CurrScr()->flags&fMAZE)
6877 {
6878 sprintf(buf,"Maze Path: %s (Exit %s)",pathstr(Map.CurrScr()->path),mazedirstr[Map.CurrScr()->exitdir]);
6879 show_screen_error(buf,i++,vc(15));
6880 }
6881
6882 bool continuescreen = false, savecombo = false;
6883
6884 if(Map.CurrScr()->flags4&fAUTOSAVE)
6885 {
6886 sprintf(buf,"Automatic Save%s Screen", (Map.CurrScr()->flags6&fCONTINUEHERE) ? "-Continue":"");
6887 show_screen_error(buf,i++,vc(15));
6888 continuescreen = ((Map.CurrScr()->flags6&fCONTINUEHERE)!=0);
6889 savecombo = true;
6890 }
6891 else if(Map.CurrScr()->flags6&fCONTINUEHERE)
6892 {
6893 sprintf(buf,"Continue Screen");
6894 show_screen_error(buf,i++,vc(15));
6895 continuescreen = true;
6896 }
6897
6898 if(isSideViewGravity())
6899 {
6900 sprintf(buf,"Sideview Gravity");
6901 show_screen_error(buf,i++,vc(15));
6902 }
6903
6904 if(Map.CurrScr()->flags6 & (fCAVEROOM|fDUNGEONROOM))
6905 {
6906 sprintf(buf,"Treat As %s%s Screen", (Map.CurrScr()->flags6&fCAVEROOM) ? "Interior":"NES Dungeon",
6907 (Map.CurrScr()->flags6 & (fCAVEROOM|fDUNGEONROOM)) == (fCAVEROOM|fDUNGEONROOM) ? " or NES Dungeon":"");
6908 show_screen_error(buf,i++,vc(15));
6909 }
6910
6911 if(Map.CurrScr()->oceansfx != 0)
6912 {
6913 sprintf(buf,"Ambient Sound: %s",sfx_string[Map.CurrScr()->oceansfx]);
6914 show_screen_error(buf,i++,vc(15));
6915 }
6916
6917 if(Map.CurrScr()->bosssfx != 0)
6918 {
6919 sprintf(buf,"Boss Roar Sound: %s",sfx_string[Map.CurrScr()->bosssfx]);
6920 show_screen_error(buf,i++,vc(15));
6921 }
6922
6923 if(Map.CurrScr()->str)
6924 {
6925 strncpy(buf,MsgString(Map.CurrScr()->str, true, false),72);
6926 buf[72] = '\0';
6927 char shortbuf[72];
6928 strip_extra_spaces(buf);
6929 shorten_string(shortbuf, buf, get_zc_font(font_lfont_l), 72, 280);
6930 sprintf(buf,"String %s",shortbuf);
6931 show_screen_error(buf,i++,vc(15));
6932 }
6933
6934 if((Map.CurrScr()->flags&fWHISTLE) || (Map.CurrScr()->flags7&fWHISTLEWATER))
6935 {
6936 sprintf(buf,"Whistle ->%s%s%s",(Map.CurrScr()->flags&fWHISTLE)?" Stairs":"",
6937 (Map.CurrScr()->flags&fWHISTLE && Map.CurrScr()->flags7&fWHISTLEWATER)?", ":"",
6938 (Map.CurrScr()->flags7&fWHISTLEWATER)?"Dry Lake":"");
6939 show_screen_error(buf,i++,vc(15));
6940 }
6941
6942 switch(Map.CurrScr()->room)
6943 {
6944 case rSP_ITEM:
6945 sprintf(buf,"Special Item is %s",item_string[Map.CurrScr()->catchall]);
6946 show_screen_error(buf,i++, vc(15));
6947 break;
6948
6949 case rINFO:
6950 {
6951 int32_t shop = Map.CurrScr()->catchall;
6952 sprintf(buf,"Pay For Info: -%d, -%d, -%d",
6953 QMisc.info[shop].price[0],QMisc.info[shop].price[1],QMisc.info[shop].price[2]);
6954 show_screen_error(buf,i++, vc(15));
6955 }
6956 break;
6957
6958 case rMONEY:
6959 sprintf(buf,"Secret Money: %d Rupees",Map.CurrScr()->catchall);
6960 show_screen_error(buf,i++, vc(15));
6961 break;
6962
6963 case rGAMBLE:
6964 show_screen_error("Gamble Room",i++, vc(15));
6965 break;
6966
6967 case rREPAIR:
6968 sprintf(buf,"Door Repair: -%d Rupees",Map.CurrScr()->catchall);
6969 show_screen_error(buf,i++, vc(15));
6970 break;
6971
6972 case rRP_HC:
6973 sprintf(buf,"Take %s or %s", item_string[iRPotion], item_string[iHeartC]);
6974 show_screen_error(buf,i++, vc(15));
6975 break;
6976
6977 case rGRUMBLE:
6978 show_screen_error("Feed the Goriya",i++, vc(15));
6979 break;
6980
6981 case rTRIFORCE:
6982 show_screen_error("Triforce Check",i++, vc(15));
6983 break;
6984
6985 case rP_SHOP:
6986 case rSHOP:
6987 {
6988 int32_t shop = Map.CurrScr()->catchall;
6989 sprintf(buf,"%sShop: ",
6990 Map.CurrScr()->room==rP_SHOP ? "Potion ":"");
6991
6992 for(int32_t j=0; j<3; j++) if(QMisc.shop[shop].item[j]>0) // Print the 3 items and prices
6993 {
6994 strcat(buf,item_string[QMisc.shop[shop].item[j]]);
6995 strcat(buf,":");
6996 char pricebuf[8];
6997 sprintf(pricebuf,"%d",QMisc.shop[shop].price[j]);
6998 strcat(buf,pricebuf);
6999
7000 if(j<2 && QMisc.shop[shop].item[j+1]>0) strcat(buf,", ");
7001 }
7002
7003 show_screen_error(buf,i++, vc(15));
7004 }
7005 break;
7006
7007 case rBOTTLESHOP:
7008 {
7009 int32_t shop = Map.CurrScr()->catchall;
7010 sprintf(buf,"Bottle Shop: ");
7011
7012 for(int32_t j=0; j<3; j++) if(QMisc.bottle_shop_types[shop].fill[j]>0) // Print the 3 fills and prices
7013 {
7014 strcat(buf,QMisc.bottle_types[QMisc.bottle_shop_types[shop].fill[j]-1].name);
7015 strcat(buf,":");
7016 char pricebuf[8];
7017 sprintf(pricebuf,"%d",QMisc.bottle_shop_types[shop].price[j]);
7018 strcat(buf,pricebuf);
7019
7020 if(j<2 && QMisc.bottle_shop_types[shop].fill[j+1]>0) strcat(buf,", ");
7021 }
7022
7023 show_screen_error(buf,i++, vc(15));
7024 }
7025 break;
7026
7027 case rTAKEONE:
7028 {
7029 int32_t shop = Map.CurrScr()->catchall;
7030 sprintf(buf,"Take Only One: %s%s%s%s%s",
7031 QMisc.shop[shop].item[0]<1?"":item_string[QMisc.shop[shop].item[0]],QMisc.shop[shop].item[0]>0?", ":"",
7032 QMisc.shop[shop].item[1]<1?"":item_string[QMisc.shop[shop].item[1]],(QMisc.shop[shop].item[1]>0&&QMisc.shop[shop].item[2]>0)?", ":"",
7033 QMisc.shop[shop].item[2]<1?"":item_string[QMisc.shop[shop].item[2]]);
7034 show_screen_error(buf,i++, vc(15));
7035 }
7036 break;
7037
7038 case rBOMBS:
7039 sprintf(buf,"More Bombs: -%d Rupees",Map.CurrScr()->catchall);
7040 show_screen_error(buf,i++, vc(15));
7041 break;
7042
7043 case rARROWS:
7044 sprintf(buf,"More Arrows: -%d Rupees",Map.CurrScr()->catchall);
7045 show_screen_error(buf,i++, vc(15));
7046 break;
7047
7048 case rSWINDLE:
7049 sprintf(buf,"Leave Life or %d Rupees",Map.CurrScr()->catchall);
7050 show_screen_error(buf,i++, vc(15));
7051 break;
7052
7053 case r10RUPIES:
7054 show_screen_error("10 Rupees",i++, vc(15));
7055 break;
7056
7057 case rGANON:
7058 show_screen_error("Ganon Room",i++, vc(15));
7059 break;
7060
7061 case rZELDA:
7062 show_screen_error("Zelda Room",i++, vc(15));
7063 break;
7064
7065 case rMUPGRADE:
7066 show_screen_error("1/2 Magic Upgrade",i++, vc(15));
7067 break;
7068
7069 case rLEARNSLASH:
7070 show_screen_error("Learn Slash",i++, vc(15));
7071 break;
7072
7073 case rWARP:
7074 sprintf(buf,"3-Stair Warp: Warp Ring %d",Map.CurrScr()->catchall);
7075 show_screen_error(buf,i++, vc(15));
7076 break;
7077 }
7078
7079 bool undercombo = false, warpa = false, warpb = false, warpc = false, warpd = false, warpr = false;
7080
7081 word num_ffcs = Map.CurrScr()->numFFC();
7082 for(int32_t c=0; c<176+128+1+num_ffcs; ++c)
7083 {
7084 // Checks both combos, secret combos, undercombos and FFCs
7085 //Fixme:
7086 int32_t ctype =
7087 combobuf[vbound(
7088 (c>=305 ? Map.CurrScr()->ffcs[c-305].data :
7089 c>=304 ? Map.CurrScr()->undercombo :
7090 c>=176 ? Map.CurrScr()->secretcombo[c-176] :
7091 !Map.CurrScr()->valid ? 0 : // Sanity check: does room combo data exist?
7092 Map.CurrScr()->data[c]
7093 ), 0, MAXCOMBOS-1)].type;
7094
7095 if(!undercombo && integrityBoolUnderCombo(Map.CurrScr(),ctype))
7096 {
7097 undercombo = true;
7098 show_screen_error("Under Combo is combo 0",i++, vc(7));
7099 }
7100
7101 // Tile Warp types
7102 switch(ctype)
7103 {
7104 case cSAVE:
7105 case cSAVE2:
7106 if(!savecombo)
7107 {
7108 savecombo = true;
7109
7110 if(integrityBoolSaveCombo(Map.CurrScr(),ctype))
7111 show_screen_error("Save Screen",i++, vc(15));
7112 else
7113 show_screen_error("Save-Continue Screen",i++, vc(15));
7114 }
7115
7116 break;
7117
7118 case cSTAIRR:
7119 case cPITR:
7120 case cSWARPR:
7121 if(!warpr && (Map.CurrScr()->tilewarptype[0]==wtCAVE || Map.CurrScr()->tilewarptype[1]==wtCAVE ||
7122 Map.CurrScr()->tilewarptype[2]==wtCAVE || Map.CurrScr()->tilewarptype[3]==wtCAVE))
7123 {
7124 warpr = true;
7125 show_screen_error("Random Tile Warp contains Cave/Item Cellar",i++, vc(7));
7126 }
7127
7128 break;
7129
7130 case cCAVED:
7131 case cPITD:
7132 case cSTAIRD:
7133 case cCAVE2D:
7134 case cSWIMWARPD:
7135 case cDIVEWARPD:
7136 case cSWARPD:
7137 if(!warpd)
7138 {
7139 warpd = true;
7140 tile_warp_notification(3,buf);
7141 show_screen_error(buf,i++, vc(15));
7142 }
7143
7144 break;
7145
7146 case cCAVEC:
7147 case cPITC:
7148 case cSTAIRC:
7149 case cCAVE2C:
7150 case cSWIMWARPC:
7151 case cDIVEWARPC:
7152 case cSWARPC:
7153 if(!warpc)
7154 {
7155 warpc = true;
7156 tile_warp_notification(2,buf);
7157 show_screen_error(buf,i++, vc(15));
7158 }
7159
7160 break;
7161
7162 case cCAVEB:
7163 case cPITB:
7164 case cSTAIRB:
7165 case cCAVE2B:
7166 case cSWIMWARPB:
7167 case cDIVEWARPB:
7168 case cSWARPB:
7169 if(!warpb)
7170 {
7171 warpb = true;
7172 tile_warp_notification(1,buf);
7173 show_screen_error(buf,i++, vc(15));
7174 }
7175
7176 break;
7177
7178 case cCAVE:
7179 case cPIT:
7180 case cSTAIR:
7181 case cCAVE2:
7182 case cSWIMWARP:
7183 case cDIVEWARP:
7184 case cSWARPA:
7185 if(!warpa)
7186 {
7187 warpa = true;
7188 tile_warp_notification(0,buf);
7189 show_screen_error(buf,i++, vc(15));
7190 }
7191
7192 break;
7193 }
7194 }
7195
7196 int32_t sidewarpnotify = 0;
7197
7198 if(Map.CurrScr()->flags2&wfUP)
7199 {
7200 side_warp_notification(Map.CurrScr()->sidewarpindex&3,0,buf);
7201 show_screen_error(buf,i++, vc(15));
7202 sidewarpnotify|=(1<<(Map.CurrScr()->sidewarpindex&3));
7203 }
7204
7205 if(Map.CurrScr()->flags2&wfDOWN)
7206 {
7207 side_warp_notification((Map.CurrScr()->sidewarpindex>>2)&3,1,buf);
7208 show_screen_error(buf,i++, vc(15));
7209 sidewarpnotify|=(1<<((Map.CurrScr()->sidewarpindex>>2)&3));
7210 }
7211
7212 if(Map.CurrScr()->flags2&wfLEFT)
7213 {
7214 side_warp_notification((Map.CurrScr()->sidewarpindex>>4)&3,2,buf);
7215 show_screen_error(buf,i++, vc(15));
7216 sidewarpnotify|=(1<<((Map.CurrScr()->sidewarpindex>>4)&3));
7217 }
7218
7219 if(Map.CurrScr()->flags2&wfRIGHT)
7220 {
7221 side_warp_notification((Map.CurrScr()->sidewarpindex>>6)&3,3,buf);
7222 show_screen_error(buf,i++, vc(15));
7223 sidewarpnotify|=(1<<((Map.CurrScr()->sidewarpindex>>6)&3));
7224 }
7225
7226 if(!(sidewarpnotify&1) && Map.CurrScr()->timedwarptics)
7227 {
7228 side_warp_notification(0,4,buf); // Timed Warp
7229 show_screen_error(buf,i++, vc(15));
7230 }
7231
7232 // Now for errors
7233 if((Map.CurrScr()->flags4&fSAVEROOM) && !savecombo) show_screen_error("Save Point->Continue Here, but no Save Point combo?",i++, vc(14));
7234
7235 if(integrityBoolEnemiesItem(Map.CurrScr())) show_screen_error("Enemies->Item, but no enemies",i++, vc(7));
7236
7237 if(integrityBoolEnemiesSecret(Map.CurrScr())) show_screen_error("Enemies->Secret, but no enemies",i++, vc(7));
7238
7239 if(integrityBoolGuyNoString(Map.CurrScr())) show_screen_error("Non-Fairy Guy, but String is (none)",i++, vc(14));
7240
7241 if(integrityBoolRoomNoGuy(Map.CurrScr())) show_screen_error("Guy is (none)",i++, vc(14));
7242
7243 if(integrityBoolRoomNoString(Map.CurrScr())) show_screen_error("String is (none)",i++, vc(14));
7244
7245 if(integrityBoolRoomNoGuyNoString(Map.CurrScr())) show_screen_error("Guy and String are (none)",i++, vc(14));
7246 }
7247
7248 if(zoom_delay)
7249 draw_screenunit(rSCRMAP,flags);
7250
7251
7252 if(flags&rCLEAR)
7253 {
7254 //Draw the whole gui
7255 blit(menu1,screen,0,0,0,0,zq_screen_w,zq_screen_h);
7256 }
7257 else
7258 {
7259 blit(menu1,screen,0,16,0,16,zq_screen_w,zq_screen_h-16);
7260 blit(menu1,screen,combolist_window.x-64,0,combolist_window.x-64,0,combolist_window.w+64,16);
7261
7262 if(flags&rCOMBO)
7263 blit(menu1,screen,combo_preview.x,combo_preview.y,combo_preview.x,combo_preview.y,combo_preview.w,combo_preview.h);
7264 }
7265
7266 if(earlyret)
7267 return;
7268
7269 //Draw the Main Menu
7270 rectfill(screen,mainbar.x,mainbar.y,mainbar.x+mainbar.w-1,mainbar.y+mainbar.h-1,jwin_pal[jcBOX]);
7271 jwin_draw_frame(screen,mainbar.x,mainbar.y,mainbar.w,mainbar.h,FR_WIN);
7272
7273 FONT* oldfont = font;
7274 font = get_custom_font(CFONT_GUI);
7275
7276 //Drawmode button
7277 draw_text_button(screen,drawmode_btn.x,drawmode_btn.y,drawmode_btn.w,drawmode_btn.h,dm_names[draw_mode],vc(1),vc(14),0,true);
7278 //Compact button
7279 draw_text_button(screen,compactbtn.x, compactbtn.y, compactbtn.w, compactbtn.h, is_compact ? "< Expand" : "> Compact", vc(1),vc(14),0,true);
7280 //Zoom buttons
7281 zoom_in_btn_disabled = num_screens_to_draw == 1;
7282 zoom_out_btn_disabled = num_screens_to_draw == mapscreen_num_screens_to_draw_max;
7283 draw_text_button(screen,zoominbtn.x, zoominbtn.y, zoominbtn.w, zoominbtn.h, "+", vc(1),vc(14),zoom_in_btn_disabled ? D_DISABLED : 0,true);
7284 draw_text_button(screen,zoomoutbtn.x, zoomoutbtn.y, zoomoutbtn.w, zoomoutbtn.h, "-", vc(1),vc(14),zoom_out_btn_disabled ? D_DISABLED : 0,true);
7285
7286 font = oldfont;
7287
7288 d_nbmenu_proc(MSG_DRAW, &dialogs[0], 0);
7289
7290 ComboBrushPause=0;
7291
7292 SCRFIX();
7293 if(update)
7294 custom_vsync();
7295 is_refreshing = refreshing = false;
7296 11 }
7297
7298 12 static int minimap_tooltip_id = ttip_register_id();
7299
7300 void select_scr()
7301 {
7302 if(Map.getCurrMap()>=Map.getMapCount())
7303 return;
7304
7305 int32_t tempcb=ComboBrush;
7306 ComboBrush=0;
7307
7308 size_and_pos const& real_mini = zoomed_minimap ? real_minimap_zoomed : real_minimap;
7309
7310 //scooby
7311 while(gui_mouse_b())
7312 {
7313 int32_t x=gui_mouse_x();
7314 int32_t y=gui_mouse_y();
7315
7316 int32_t ind = real_mini.rectind(x,y);
7317
7318 if(ind>=MAPSCRS)
7319 ind-=16;
7320
7321 if(ind > -1 && ind != Map.getCurrScr())
7322 {
7323 Map.setCurrScr(ind);
7324 }
7325
7326 custom_vsync();
7327 refresh(rALL);
7328 }
7329
7330 ComboBrush=tempcb;
7331 }
7332
7333 void clear_cpool()
7334 {
7335 for(int32_t i=0; i<MAXFAVORITECOMBOS; ++i)
7336 {
7337 pool_combos[i].clear();
7338 }
7339 pool_dirty = true;
7340 }
7341
7342 bool select_favorite()
7343 {
7344 int32_t tempcb=ComboBrush;
7345 ComboBrush=0;
7346 bool valid=false;
7347
7348 while(gui_mouse_b())
7349 {
7350 valid=false;
7351 int32_t x=gui_mouse_x();
7352
7353 if(x<favorites_list.x)
7354 x=favorites_list.x;
7355
7356 if(x>favorites_list.x+(favorites_list.w*favorites_list.xscale)-1)
7357 x=favorites_list.x+(favorites_list.w*favorites_list.xscale)-1;
7358
7359 int32_t y=gui_mouse_y();
7360
7361 if(y<favorites_list.y)
7362 y=favorites_list.y;
7363
7364 if(y>favorites_list.y+(favorites_list.h*favorites_list.yscale)-1)
7365 y=favorites_list.y+(favorites_list.h*favorites_list.yscale)-1;
7366
7367 int32_t tempc=(((y-favorites_list.y)/favorites_list.yscale)*FAVORITECOMBO_PER_ROW)+((x-favorites_list.x)/favorites_list.xscale) + FAVORITECOMBO_PER_PAGE * FavoriteComboPage;
7368
7369 if(tempc >= MAXFAVORITECOMBOS)
7370 {
7371 //Nothing, invalid
7372 }
7373 else
7374 {
7375 if(favorite_combos[tempc]!=-1)
7376 {
7377 switch(favorite_combo_modes[tempc])
7378 {
7379 case dm_alias:
7380 draw_mode = dm_alias;
7381 combo_apos = favorite_combos[tempc];
7382 break;
7383 case dm_cpool:
7384 draw_mode = dm_cpool;
7385 combo_pool_pos = favorite_combos[tempc];
7386 break;
7387 case dm_auto:
7388 draw_mode = dm_auto;
7389 combo_auto_pos = favorite_combos[tempc];
7390 break;
7391 default:
7392 draw_mode = dm_normal;
7393 Combo = favorite_combos[tempc];
7394 }
7395 if(AutoBrush)
7396 BrushWidth = BrushHeight = 1;
7397 valid=true;
7398 fix_drawing_mode_menu();
7399 }
7400 }
7401
7402 custom_vsync();
7403 refresh(rALL);
7404 }
7405
7406 ComboBrush=tempcb;
7407 return valid;
7408 }
7409
7410 void select_combo(int32_t clist)
7411 {
7412 current_combolist=clist;
7413 int32_t tempcb=ComboBrush;
7414 ComboBrush=0;
7415
7416 int autobrush_cx = -1, autobrush_cy = -1;
7417 int autobrush_first = First[current_combolist];
7418 auto& curlist = combolist[current_combolist];
7419 AutoBrushRevert = (key[KEY_ALT]||key[KEY_ALTGR]);
7420 while(gui_mouse_b())
7421 {
7422 int32_t x=gui_mouse_x();
7423
7424 if(x<curlist.x)
7425 x=curlist.x;
7426
7427 if(x>curlist.x+(curlist.w*curlist.xscale)-1)
7428 x=curlist.x+(curlist.w*curlist.xscale)-1;
7429
7430 int32_t y=gui_mouse_y();
7431
7432 if(y<curlist.y)
7433 y=curlist.y;
7434
7435 if(y>curlist.y+(curlist.h*curlist.yscale)-1)
7436 y=curlist.y+(curlist.h*curlist.yscale)-1;
7437
7438 int cx = ((x-curlist.x)/curlist.xscale), cy = ((y-curlist.y)/curlist.yscale);
7439 if(AutoBrush)
7440 {
7441 if(autobrush_cx < 0)
7442 {
7443 autobrush_cx = cx;
7444 autobrush_cy = cy;
7445 }
7446 BrushWidth = vbound(abs(autobrush_cx-cx)+1,1,16);
7447 BrushHeight = vbound(abs(autobrush_cy-cy)+1,1,11);
7448 cx = std::min(autobrush_cx,cx);
7449 cy = std::min(autobrush_cy,cy);
7450 }
7451 Combo=(cy*curlist.w)+cx+First[current_combolist];
7452 custom_vsync();
7453 refresh(rALL);
7454 if(AutoBrush) //Prevent any scrolling
7455 First[current_combolist] = autobrush_first;
7456 }
7457 if(key[KEY_ALT]||key[KEY_ALTGR])
7458 AutoBrushRevert = true;
7459 position_mouse_z(0);
7460 ComboBrush=tempcb;
7461 }
7462
7463 void select_comboa(int32_t clist)
7464 {
7465 current_comboalist=clist;
7466 int32_t tempcb=ComboBrush;
7467 ComboBrush=0;
7468 alias_cset_mod=0;
7469
7470 auto& curlist = comboaliaslist[current_comboalist];
7471 while(gui_mouse_b())
7472 {
7473 int32_t x=gui_mouse_x();
7474
7475 if(x<curlist.x)
7476 x=curlist.x;
7477
7478 if(x>curlist.x+(curlist.w*curlist.xscale)-1)
7479 x=curlist.x+(curlist.w*curlist.xscale)-1;
7480
7481 int32_t y=gui_mouse_y();
7482
7483 if(y<curlist.y)
7484 y=curlist.y;
7485
7486 if(y>curlist.y+(curlist.h*curlist.yscale)-1)
7487 y=curlist.y+(curlist.h*curlist.yscale)-1;
7488
7489 combo_apos=(((y-curlist.y)/curlist.yscale)*curlist.w)+((x-curlist.x)/curlist.xscale)+combo_alistpos[current_comboalist];
7490 custom_vsync();
7491 refresh(rALL);
7492 }
7493
7494 ComboBrush=tempcb;
7495 }
7496
7497 void select_combop(int32_t clist)
7498 {
7499 current_cpoollist=clist;
7500 int32_t tempcb=ComboBrush;
7501 ComboBrush=0;
7502
7503 auto& curlist = comboaliaslist[current_cpoollist];
7504 while(gui_mouse_b())
7505 {
7506 int32_t x=gui_mouse_x();
7507
7508 if(x<curlist.x) x=curlist.x;
7509
7510 if(x>curlist.x+(curlist.w*curlist.xscale)-1)
7511 x=curlist.x+(curlist.w*curlist.xscale)-1;
7512
7513 int32_t y=gui_mouse_y();
7514
7515 if(y<curlist.y) y=curlist.y;
7516
7517 if(y>curlist.y+(curlist.h*curlist.yscale)-1)
7518 y=curlist.y+(curlist.h*curlist.yscale)-1;
7519
7520 combo_pool_pos=(((y-curlist.y)/curlist.yscale)*curlist.w)+((x-curlist.x)/curlist.xscale)+combo_pool_listpos[current_cpoollist];
7521 custom_vsync();
7522 refresh(rALL);
7523 }
7524
7525 ComboBrush=tempcb;
7526 }
7527
7528 void select_autocombo(int32_t clist)
7529 {
7530 current_cautolist = clist;
7531 int32_t tempcb = ComboBrush;
7532 ComboBrush = 0;
7533
7534 auto& curlist = comboaliaslist[current_cautolist];
7535 while (gui_mouse_b())
7536 {
7537 int32_t x = gui_mouse_x();
7538
7539 if (x < curlist.x) x = curlist.x;
7540
7541 if (x > curlist.x + (curlist.w * curlist.xscale) - 1)
7542 x = curlist.x + (curlist.w * curlist.xscale) - 1;
7543
7544 int32_t y = gui_mouse_y();
7545
7546 if (y < curlist.y) y = curlist.y;
7547
7548 if (y > curlist.y + (curlist.h * curlist.yscale) - 1)
7549 y = curlist.y + (curlist.h * curlist.yscale) - 1;
7550
7551 combo_auto_pos = (((y - curlist.y) / curlist.yscale) * curlist.w) + ((x - curlist.x) / curlist.xscale) + combo_auto_listpos[current_cautolist];
7552 cauto_height = combo_autos[combo_auto_pos].getArg() + 1;
7553 custom_vsync();
7554 refresh(rALL);
7555 }
7556
7557 ComboBrush = tempcb;
7558 }
7559
7560 void update_combobrush()
7561 {
7562 clear_bitmap(brushbmp);
7563
7564 if(draw_mode==dm_alias)
7565 {
7566 //int32_t count=(combo_aliases[combo_apos].width+1)*(combo_aliases[combo_apos].height+1)*(comboa_lmasktotal(combo_aliases[combo_apos].layermask));
7567 for(int32_t z=0; z<=comboa_lmasktotal(combo_aliases[combo_apos].layermask); z++)
7568 {
7569 for(int32_t y=0; y<=combo_aliases[combo_apos].height; y++)
7570 {
7571 for(int32_t x=0; x<=combo_aliases[combo_apos].width; x++)
7572 {
7573 int32_t position = ((y*(combo_aliases[combo_apos].width+1))+x)+((combo_aliases[combo_apos].width+1)*(combo_aliases[combo_apos].height+1)*z);
7574
7575 if(combo_aliases[combo_apos].combos[position])
7576 {
7577 if(z==0)
7578 {
7579 putcombo(brushbmp,x<<4,y<<4,combo_aliases[combo_apos].combos[position],wrap(combo_aliases[combo_apos].csets[position]+alias_cset_mod, 0, 13));
7580 }
7581 else
7582 {
7583 overcombo(brushbmp,x<<4,y<<4,combo_aliases[combo_apos].combos[position],wrap(combo_aliases[combo_apos].csets[position]+alias_cset_mod, 0, 13));
7584 }
7585 }
7586 }
7587 }
7588 }
7589
7590 int xoff = 6, yoff = 6;
7591 if(FloatBrush) // Offset the floating pixels, so the 'x' appears centered on the combo still -Em
7592 {
7593 xoff += 2;
7594 yoff += 2;
7595 }
7596 if(alias_origin & 1) // Right-align
7597 xoff += combo_aliases[combo_apos].width*16;
7598 if(alias_origin & 2) // Bottom-align
7599 yoff += combo_aliases[combo_apos].height*16;
7600
7601 textprintf_shadowed_ex(brushbmp, get_zc_font(font_sfont), xoff, yoff, vc(15), vc(0), -1, "x");
7602 }
7603 else if(draw_mode != dm_cpool)
7604 {
7605 int32_t cid = combobrushoverride > -1 ? combobrushoverride : Combo;
7606 int32_t c = 0;
7607
7608 for(int32_t i=0; i<256; i++)
7609 {
7610 if(unsigned(cid+c) >= MAXCOMBOS) break;
7611 if(((i%COMBOS_PER_ROW)<BrushWidth)&&((i/COMBOS_PER_ROW)<BrushHeight))
7612 {
7613 put_combo(brushbmp,(i%COMBOS_PER_ROW)<<4,(i/COMBOS_PER_ROW)<<4,cid+c,CSet,Flags&(cFLAGS|cWALK),0);
7614 }
7615
7616 if(((cid+c)&3)==3)
7617 c+=48;
7618
7619 ++c;
7620
7621 if((i%COMBOS_PER_ROW)==(COMBOS_PER_ROW-1))
7622 c-=256;
7623 }
7624 }
7625 }
7626
7627 byte relational_source_grid[256]=
7628 {
7629 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
7630 16, 16, 17, 17, 18, 18, 19, 19, 16, 16, 17, 17, 18, 18, 19, 19,
7631 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23,
7632 24, 24, 24, 24, 25, 25, 25, 25, 24, 24, 24, 24, 25, 25, 25, 25,
7633 26, 27, 26, 27, 26, 27, 26, 27, 28, 29, 28, 29, 28, 29, 28, 29,
7634 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
7635 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
7636 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
7637 34, 35, 36, 37, 34, 35, 36, 37, 34, 35, 36, 37, 34, 35, 36, 37,
7638 38, 38, 39, 39, 38, 38, 39, 39, 38, 38, 39, 39, 38, 38, 39, 39,
7639 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
7640 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
7641 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43,
7642 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
7643 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
7644 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46
7645 };
7646
7647 static void draw_autocombo(ComboPosition combo_pos, bool rclick, bool pressframe = false)
7648 {
7649 combo_auto &ca = combo_autos[combo_auto_pos];
7650 int screen = Map.getScreenForPosition(combo_pos);
7651 int pos = combo_pos.truncate();
7652
7653 if (ca.valid())
7654 {
7655 switch (ca.getType())
7656 {
7657 case AUTOCOMBO_BASIC:
7658 {
7659 AutoPattern::autopattern_basic ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7660 if (rclick)
7661 ap.erase(screen, pos);
7662 else
7663 ap.execute(screen, pos);
7664 break;
7665 }
7666 case AUTOCOMBO_Z1:
7667 {
7668 AutoPattern::autopattern_flatmtn ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7669 if (rclick)
7670 ap.erase(screen, pos);
7671 else
7672 ap.execute(screen, pos);
7673 break;
7674 }
7675 case AUTOCOMBO_FENCE:
7676 {
7677 AutoPattern::autopattern_fence ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7678 if (rclick)
7679 ap.erase(screen, pos);
7680 else
7681 ap.execute(screen, pos);
7682 break;
7683 }
7684 case AUTOCOMBO_Z4:
7685 {
7686 AutoPattern::autopattern_cakemtn ap(ca.getType(), CurrentLayer, screen, pos, &ca, cauto_height);
7687 if (rclick)
7688 ap.erase(screen, pos);
7689 else
7690 ap.execute(screen, pos);
7691 break;
7692 }
7693 case AUTOCOMBO_RELATIONAL:
7694 {
7695 AutoPattern::autopattern_relational ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7696 if (rclick)
7697 ap.erase(screen, pos);
7698 else
7699 ap.execute(screen, pos);
7700 break;
7701 }
7702 case AUTOCOMBO_DGNCARVE:
7703 {
7704 AutoPattern::autopattern_dungeoncarve ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7705 if (rclick)
7706 ap.erase(screen, pos);
7707 else
7708 ap.execute(screen, pos);
7709 break;
7710 }
7711 case AUTOCOMBO_DOR:
7712 {
7713 AutoPattern::autopattern_dormtn ap(ca.getType(), CurrentLayer, screen, pos, &ca, cauto_height);
7714 if (rclick)
7715 ap.erase(screen, pos);
7716 else
7717 ap.execute(screen, pos);
7718 break;
7719 }
7720 case AUTOCOMBO_TILING:
7721 {
7722 if (pressframe && (key[KEY_LSHIFT] || key[KEY_RSHIFT]))
7723 {
7724 int32_t x = (screen % 16) * 16 + (pos % 16);
7725 int32_t y = (screen / 16) * 11 + (pos / 16);
7726 byte w = (ca.getArg() & 0xF) + 1;
7727 byte h = ((ca.getArg() >> 4) & 0xF) + 1;
7728 ca.setOffsets(x % w, y % h);
7729 }
7730 AutoPattern::autopattern_tiling ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7731 if (rclick)
7732 ap.erase(screen, pos);
7733 else
7734 ap.execute(screen, pos);
7735 break;
7736 }
7737 case AUTOCOMBO_REPLACE:
7738 {
7739 AutoPattern::autopattern_replace ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7740 if (rclick)
7741 ap.erase(screen, pos);
7742 else
7743 ap.execute(screen, pos);
7744 break;
7745 }
7746 case AUTOCOMBO_DENSEFOREST:
7747 {
7748 if (pressframe && (key[KEY_LSHIFT] || key[KEY_RSHIFT]))
7749 {
7750 int32_t x = (screen % 16) * 16 + (pos % 16);
7751 int32_t y = (screen / 16) * 11 + (pos / 16);
7752 ca.setOffsets(x % 2, y % 2);
7753 }
7754 AutoPattern::autopattern_denseforest ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7755 if (rclick)
7756 ap.erase(screen, pos);
7757 else
7758 ap.execute(screen, pos);
7759 break;
7760 }
7761 case AUTOCOMBO_EXTEND:
7762 {
7763 if (CHECK_CTRL_CMD)
7764 break;
7765 AutoPattern::autopattern_extend ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7766 if (rclick)
7767 ap.erase(screen, pos);
7768 else
7769 ap.execute(screen, pos);
7770 break;
7771 }
7772 }
7773 }
7774 else
7775 {
7776 ca.updateValid();
7777 if(!ca.valid())
7778 InfoDialog("Notice", "The autocombo you're trying to use is invalid. Reason:"
7779 + ca.getInvalidReason()).show();
7780 }
7781 }
7782
7783 static void draw_autocombo_command(ComboPosition combo_pos, int32_t cmd = 0, int32_t arg = 0)
7784 {
7785 combo_auto ca = combo_autos[combo_auto_pos];
7786 int screen = Map.getScreenForPosition(combo_pos);
7787 int pos = combo_pos.truncate();
7788
7789 if (ca.valid())
7790 {
7791 switch (ca.getType())
7792 {
7793 case AUTOCOMBO_FENCE:
7794 {
7795 AutoPattern::autopattern_fence ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7796 ap.flip_all_connected(screen, pos, 2048);
7797 break;
7798 }
7799 case AUTOCOMBO_Z4:
7800 {
7801 AutoPattern::autopattern_cakemtn ap(ca.getType(), CurrentLayer, screen, pos, &ca, cauto_height);
7802 switch (cmd)
7803 {
7804 case 0: // Flip
7805 ap.flip_all_connected(screen, pos, 2048);
7806 break;
7807 case 1: // Grow
7808 ap.resize_connected(screen, pos, 2048, vbound(arg, 1, 9));
7809 break;
7810 }
7811 }
7812 }
7813 }
7814 }
7815
7816 static int32_t get_autocombo_floating_cid(ComboPosition combo_pos, bool clicked)
7817 {
7818 combo_auto& ca = combo_autos[combo_auto_pos];
7819 int screen = Map.getScreenForPosition(combo_pos);
7820 int pos = combo_pos.truncate();
7821 int cid = 0;
7822
7823 if (ca.valid() && Map.isValidPosition(mouse_combo_pos))
7824 {
7825 switch (ca.getType())
7826 {
7827 case AUTOCOMBO_BASIC:
7828 {
7829 AutoPattern::autopattern_basic ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7830 cid = ap.get_floating_cid(screen, pos);
7831 break;
7832 }
7833
7834 case AUTOCOMBO_Z1:
7835 {
7836 AutoPattern::autopattern_flatmtn ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7837 cid = ap.get_floating_cid(screen, pos);
7838 break;
7839 }
7840 case AUTOCOMBO_FENCE:
7841 {
7842 AutoPattern::autopattern_fence ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7843 cid = ap.get_floating_cid(screen, pos);
7844 break;
7845 }
7846 case AUTOCOMBO_Z4:
7847 {
7848 AutoPattern::autopattern_cakemtn ap(ca.getType(), CurrentLayer, screen, pos, &ca, cauto_height);
7849 cid = ap.get_floating_cid(screen, pos);
7850 break;
7851 }
7852 case AUTOCOMBO_RELATIONAL:
7853 {
7854 AutoPattern::autopattern_relational ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7855 cid = ap.get_floating_cid(screen, pos);
7856 break;
7857 }
7858 case AUTOCOMBO_DGNCARVE:
7859 {
7860 AutoPattern::autopattern_dungeoncarve ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7861 cid = ap.get_floating_cid(screen, pos);
7862 break;
7863 }
7864 case AUTOCOMBO_DOR:
7865 {
7866 AutoPattern::autopattern_dormtn ap(ca.getType(), CurrentLayer, screen, pos, &ca, cauto_height);
7867 cid = ap.get_floating_cid(screen, pos);
7868 break;
7869 }
7870 case AUTOCOMBO_TILING:
7871 {
7872 std::pair<byte, byte> offs = ca.getOffsets();
7873 if (!clicked && (key[KEY_LSHIFT] || key[KEY_RSHIFT]))
7874 {
7875 int32_t x = (screen % 16) * 16 + (pos % 16);
7876 int32_t y = (screen / 16) * 11 + (pos / 16);
7877 byte w = (ca.getArg() & 0xF) + 1;
7878 byte h = ((ca.getArg() >> 4) & 0xF) + 1;
7879 offs.first = (x % w);
7880 offs.second = (y % h);
7881 }
7882 AutoPattern::autopattern_tiling ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7883 cid = ap.get_floating_cid(screen, pos);
7884 break;
7885 }
7886 case AUTOCOMBO_REPLACE:
7887 {
7888 AutoPattern::autopattern_replace ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7889 cid = ap.get_floating_cid(screen, pos);
7890 break;
7891 }
7892 case AUTOCOMBO_DENSEFOREST:
7893 {
7894 AutoPattern::autopattern_denseforest ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7895 cid = ap.get_floating_cid(screen, pos);
7896 break;
7897 }
7898 case AUTOCOMBO_EXTEND:
7899 {
7900 AutoPattern::autopattern_extend ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7901 cid = ap.get_floating_cid(screen, pos);
7902 break;
7903 }
7904 }
7905 }
7906 return cid;
7907 }
7908
7909 void change_autocombo_height(int32_t change)
7910 {
7911 bool can_change = false;
7912 if (draw_mode == dm_auto)
7913 {
7914 combo_auto ca = combo_autos[combo_auto_pos];
7915 switch (ca.getType())
7916 {
7917 case AUTOCOMBO_Z4:
7918 can_change = true;
7919 [[fallthrough]];
7920 case AUTOCOMBO_DOR:
7921 break;
7922 default:
7923 return;
7924 }
7925 }
7926 else
7927 return;
7928
7929 int32_t x = gui_mouse_x();
7930 int32_t y = gui_mouse_y();
7931 double startx = mapscreen_x + (showedges ? (16 * mapscreen_single_scale) : 0);
7932 double starty = mapscreen_y + (showedges ? (16 * mapscreen_single_scale) : 0);
7933 int32_t startxint = mapscreen_x + (showedges ? int32_t(16 * mapscreen_single_scale) : 0);
7934 int32_t startyint = mapscreen_y + (showedges ? int32_t(16 * mapscreen_single_scale) : 0);
7935 ComboPosition pos = get_mapscreen_mouse_combo_pos();
7936
7937 if (can_change && isinRect(x, y, startxint, startyint, int32_t(startx + (256 * mapscreen_single_scale) - 1), int32_t(starty + (176 * mapscreen_single_scale) - 1)))
7938 {
7939 Map.StartListCommand();
7940 draw_autocombo_command(pos, 1, cauto_height + change);
7941 Map.FinishListCommand();
7942 }
7943 cauto_height = vbound(cauto_height + change, 1, 9);
7944 }
7945
7946 void draw(bool justcset)
7947 {
7948 combo_pool const& pool = combo_pools[combo_pool_pos];
7949 if(draw_mode == dm_cpool && !pool.valid())
7950 return;
7951 saved=false;
7952
7953 refresh(rMAP+rSCRMAP);
7954 ComboPosition last_pos = {-1, -1};
7955
7956 Map.StartListCommand();
7957 bool pressframe = true;
7958 while(gui_mouse_b())
7959 {
7960 int32_t x=gui_mouse_x();
7961 int32_t y=gui_mouse_y();
7962 double startx=mapscreen_x+(showedges?(16*mapscreen_single_scale):0);
7963 double starty=mapscreen_y+(showedges?(16*mapscreen_single_scale):0);
7964 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreen_single_scale):0);
7965 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreen_single_scale):0);
7966 int num_combos_width = 16 * Map.getViewSize();
7967 int num_combos_height = 11 * Map.getViewSize();
7968
7969 if(isinRect(x,y,startxint,startyint,int32_t(startx+(256*mapscreen_screenunit_scale)-1),int32_t(starty+(176*mapscreen_screenunit_scale)-1)))
7970 {
7971 int32_t cxstart=(x-startx)/(16*mapscreen_single_scale);
7972 int32_t cystart=(y-starty)/(16*mapscreen_single_scale);
7973 ComboPosition combo_start = {cxstart, cystart};
7974 if (pressframe)
7975 {
7976 last_pos = combo_start;
7977 }
7978 else if (combo_start == last_pos)
7979 {
7980 custom_vsync();
7981 refresh(rALL);
7982 continue;
7983 }
7984 else if(draw_mode == dm_auto)
7985 {
7986 // TODO: support when zoomed out.
7987 if (combo_autos[combo_auto_pos].getType() == AUTOCOMBO_FENCE || combo_autos[combo_auto_pos].getType() == AUTOCOMBO_Z4)
7988 {
7989 // Don't allow moving the brush at anything but cardinal directions while in these modes
7990 bool did_diag = std::abs(combo_start.x - last_pos.x) == 1 && std::abs(combo_start.y - last_pos.y) == 1;
7991
7992 if (did_diag)
7993 {
7994 int32_t oldx = last_pos.x;
7995 int32_t oldy = last_pos.y;
7996 int32_t cx = (oldx * 16 * mapscreen_single_scale) + 8;
7997 int32_t cy = (oldy * 16 * mapscreen_single_scale) + 8;
7998 int32_t nx = x - startxint;
7999 int32_t ny = y - startyint;
8000 if (std::abs(nx - cx) < std::abs(ny - cy))
8001 {
8002 oldy = vbound(oldy + ((ny - cy) < 0 ? -1 : 1), 0, 11);
8003 }
8004 else
8005 {
8006 oldx = vbound(oldx + ((nx - cx) < 0 ? -1 : 1), 0, 15);
8007 }
8008 combo_start = {oldx, oldy};
8009 }
8010 }
8011 }
8012 last_pos = combo_start;
8013
8014 switch(draw_mode)
8015 {
8016 case dm_normal:
8017 {
8018 int32_t cc=Combo;
8019
8020 for(int32_t cy=0; cy+cystart<num_combos_height&&cy<BrushHeight; cy++)
8021 {
8022 for(int32_t cx=0; cx+cxstart<num_combos_width&&cx<BrushWidth; cx++)
8023 {
8024 auto pos = combo_start + ComboPosition{cx, cy};
8025 cc=Combo + cx + cy*4;
8026 Map.DoSetComboCommand(pos, justcset ? -1 : cc, CSet);
8027 }
8028 }
8029
8030 update_combobrush();
8031 }
8032 break;
8033 case dm_cpool:
8034 {
8035 int32_t cid = Combo;
8036 int8_t cs = CSet;
8037 pool.pick(cid,cs);
8038 Map.DoSetComboCommand(combo_start, justcset ? -1 : cid, cs);
8039
8040 update_combobrush();
8041 }
8042 break;
8043
8044 case dm_alias:
8045 {
8046 combo_alias *combo = &combo_aliases[combo_apos];
8047 if(!combo->layermask)
8048 {
8049 int32_t ox=0, oy=0;
8050
8051 switch(alias_origin)
8052 {
8053 case 0:
8054 ox=0;
8055 oy=0;
8056 break;
8057
8058 case 1:
8059 ox=(combo->width);
8060 oy=0;
8061 break;
8062
8063 case 2:
8064 ox=0;
8065 oy=(combo->height);
8066 break;
8067
8068 case 3:
8069 ox=(combo->width);
8070 oy=(combo->height);
8071 break;
8072 }
8073
8074 for(int32_t cy=0; cy-oy+cystart<num_combos_height&&cy<=combo->height; cy++)
8075 {
8076 for(int32_t cx=0; cx-ox+cxstart<num_combos_width&&cx<=combo->width; cx++)
8077 {
8078 if((cx+cxstart-ox>=0)&&(cy+cystart-oy>=0))
8079 {
8080 int32_t p=(cy*(combo->width+1))+cx;
8081
8082 if(combo->combos[p])
8083 {
8084 auto pos = combo_start + ComboPosition{cx - ox, cy - oy};
8085 Map.DoSetComboCommand(pos, combo->combos[p], wrap(combo->csets[p]+alias_cset_mod, 0, 13));
8086 }
8087 }
8088 }
8089 }
8090 }
8091 else
8092 {
8093 int32_t laypos = 0;
8094 int32_t ox=0, oy=0;
8095
8096 switch(alias_origin)
8097 {
8098 case 0:
8099 ox=0;
8100 oy=0;
8101 break;
8102
8103 case 1:
8104 ox=(combo->width);
8105 oy=0;
8106 break;
8107
8108 case 2:
8109 ox=0;
8110 oy=(combo->height);
8111 break;
8112
8113 case 3:
8114 ox=(combo->width);
8115 oy=(combo->height);
8116 break;
8117 }
8118
8119 for(int32_t cz=0; cz<7; cz++)
8120 {
8121 if (cz > 0 && !(combo->layermask & (1<<(cz-1))))
8122 continue;
8123
8124 if (cz > 0)
8125 laypos++;
8126
8127 for(int32_t cy=0; cy-oy+cystart<num_combos_height&&cy<=combo->height; cy++)
8128 {
8129 for(int32_t cx=0; cx-ox+cxstart<num_combos_width&&cx<=combo->width; cx++)
8130 {
8131 if((cx+cxstart-ox>=0)&&(cy+cystart-oy>=0))
8132 {
8133 int32_t p=((cy*(combo->width+1))+cx)+((combo->width+1)*(combo->height+1)*laypos);
8134
8135 if (combo->combos[p])
8136 {
8137 auto pos = combo_start + ComboPosition{cx - ox, cy - oy};
8138 if(cz > 0 && Map.Scr(pos)->layermap[cz - 1] == 0)
8139 continue;
8140 int prev = CurrentLayer;
8141 CurrentLayer = cz;
8142 Map.DoSetComboCommand(pos, combo->combos[p], wrap(combo->csets[p]+alias_cset_mod, 0, 13));
8143 CurrentLayer = prev;
8144 }
8145 }
8146 }
8147 }
8148 }
8149 }
8150
8151 break;
8152 }
8153
8154 case dm_auto:
8155 {
8156 draw_autocombo(combo_start, gui_mouse_b() & 2, pressframe);
8157
8158 combobrushoverride = get_autocombo_floating_cid(combo_start, true);
8159 update_combobrush();
8160 }
8161 }
8162 }
8163 pressframe = false;
8164
8165 custom_vsync();
8166 refresh(rALL);
8167 }
8168
8169 Map.FinishListCommand();
8170 if(AutoBrushRevert)
8171 {
8172 AutoBrushRevert = false;
8173 BrushWidth = 1;
8174 BrushHeight = 1;
8175 }
8176 }
8177
8178 static void replace(ComboPosition start)
8179 {
8180 int32_t cid = Combo;
8181 int8_t cs = CSet;
8182 combo_pool const& pool = combo_pools[combo_pool_pos];
8183 if(draw_mode == dm_cpool && !pool.valid())
8184 return;
8185
8186 int c = start.truncate();
8187 mapscr* scr = Map.Scr(start, CurrentLayer);
8188 if (!scr) return;
8189
8190 int num_combos_width = 16 * Map.getViewSize();
8191 int num_combos_height = 11 * Map.getViewSize();
8192 int targetcombo = scr->data[c];
8193 int targetcset = scr->cset[c];
8194
8195 saved = false;
8196 Map.StartListCommand();
8197 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
8198 {
8199 for (int x = 0; x < num_combos_width; x++)
8200 {
8201 for (int y = 0; y < num_combos_height; y++)
8202 {
8203 ComboPosition pos = {x, y};
8204 int c = pos.truncate();
8205 mapscr* scr = Map.Scr(pos, CurrentLayer);
8206 if (!scr)
8207 continue;
8208
8209 if ((scr->cset[c]) == targetcset)
8210 {
8211 if(draw_mode == dm_cpool)
8212 pool.pick(cid,cs);
8213 Map.DoSetComboCommand(pos, -1, cs);
8214 }
8215 }
8216 }
8217 }
8218 else
8219 {
8220 for (int x = 0; x < num_combos_width; x++)
8221 {
8222 for (int y = 0; y < num_combos_height; y++)
8223 {
8224 ComboPosition pos = {x, y};
8225 int c = pos.truncate();
8226 mapscr* scr = Map.Scr(pos, CurrentLayer);
8227 if (!scr)
8228 continue;
8229
8230 if(((scr->data[c])==targetcombo) &&
8231 ((scr->cset[c])==targetcset))
8232 {
8233 if(draw_mode == dm_cpool)
8234 pool.pick(cid,cs);
8235 Map.DoSetComboCommand(pos, cid, cs);
8236 }
8237 }
8238 }
8239 }
8240 Map.FinishListCommand();
8241
8242 refresh(rMAP);
8243 }
8244
8245 static void draw_block(ComboPosition start, int32_t w, int32_t h)
8246 {
8247 int32_t cid = Combo;
8248 int8_t cs = CSet;
8249 if(draw_mode == dm_cpool)
8250 {
8251 combo_pool const& pool = combo_pools[combo_pool_pos];
8252 if(!pool.pick(cid,cs)) return;
8253 }
8254
8255 mapscr* scr = Map.Scr(start, CurrentLayer);
8256 if (!scr) return;
8257
8258 saved = false;
8259 Map.StartListCommand();
8260 for (int32_t y=0; y < h && y < 11*Map.getViewSize(); y++)
8261 for (int32_t x=0; x < w && x < 16*Map.getViewSize(); x++)
8262 {
8263 Map.DoSetComboCommand(start + ComboPosition{x, y}, cid+(y*4)+x, cs);
8264 }
8265
8266 Map.FinishListCommand();
8267 refresh(rMAP+rSCRMAP);
8268 }
8269
8270 static std::vector<ComboPosition> flood_filler(ComboPosition start_pos, bool allow_diagonal, std::function<bool(ComboPosition)> check)
8271 {
8272 std::vector<ComboPosition> seen, queue;
8273
8274 queue.push_back(start_pos);
8275 while (!queue.empty())
8276 {
8277 ComboPosition pos = queue.back();
8278 queue.pop_back();
8279 seen.push_back(pos);
8280
8281 ComboPosition pos2;
8282 #define FLOOD_FILLER_CHECK(dx, dy)\
8283 pos2 = pos + ComboPosition{dx, dy};\
8284 if (std::find(seen.begin(), seen.end(), pos2) == seen.end() && check(pos2))\
8285 queue.push_back(pos2);
8286
8287 FLOOD_FILLER_CHECK(0, 1);
8288 FLOOD_FILLER_CHECK(0, -1);
8289 FLOOD_FILLER_CHECK(1, 0);
8290 FLOOD_FILLER_CHECK(-1, 0);
8291
8292 if (allow_diagonal)
8293 {
8294 FLOOD_FILLER_CHECK(1, 1);
8295 FLOOD_FILLER_CHECK(1, -1);
8296 FLOOD_FILLER_CHECK(-1, 1);
8297 FLOOD_FILLER_CHECK(-1, -1);
8298 }
8299
8300 #undef FLOOD_FILLER_CHECK
8301 }
8302
8303 return seen;
8304 }
8305
8306 static void fill(int32_t targetcombo, int32_t targetcset, ComboPosition start_pos, bool allow_diagonal, bool only_cset)
8307 {
8308 bool rclick = gui_mouse_b() & 2;
8309 bool ignored_combo = false;
8310
8311 mapscr* scr = Map.ScrMakeValid(start_pos, CurrentLayer);
8312 if (!scr)
8313 return;
8314
8315 int num_combos_width = 16 * Map.getViewSize();
8316 int num_combos_height = 11 * Map.getViewSize();
8317
8318 auto combo_positions = flood_filler(start_pos, allow_diagonal, [&](ComboPosition pos){
8319 if (pos.x < 0 || pos.y < 0 || pos.x >= num_combos_width || pos.y >= num_combos_height)
8320 return false;
8321
8322 mapscr* scr = Map.Scr(pos, CurrentLayer);
8323 if (!scr || !scr->is_valid())
8324 return false;
8325
8326 int cid = scr->data[pos.truncate()];
8327 int cset = scr->cset[pos.truncate()];
8328
8329 if (draw_mode == dm_auto)
8330 {
8331 combo_auto const& cauto = combo_autos[combo_auto_pos];
8332
8333 ignored_combo = cauto.isIgnoredCombo(cid);
8334 if (rclick)
8335 {
8336 if (cauto.containsCombo(targetcombo))
8337 {
8338 if (!cauto.containsCombo(cid))
8339 return false;
8340 if (cauto.getType() == AUTOCOMBO_REPLACE && ignored_combo)
8341 return false;
8342 }
8343 else
8344 return false;
8345 }
8346 else
8347 {
8348 if (cid != targetcombo && !ignored_combo)
8349 return false;
8350 if (cauto.getType() == AUTOCOMBO_REPLACE && !ignored_combo)
8351 return false;
8352 }
8353
8354 if (cset != targetcset && !ignored_combo)
8355 return false;
8356 }
8357 else
8358 {
8359 if(!only_cset)
8360 {
8361 if (cid != targetcombo)
8362 return false;
8363 }
8364
8365 if (cset != targetcset)
8366 return false;
8367 }
8368
8369 return true;
8370 });
8371
8372 for (auto& pos : combo_positions)
8373 {
8374 int32_t cid = Combo;
8375 int8_t cs = CSet;
8376
8377 if (draw_mode == dm_cpool)
8378 {
8379 combo_pool const& pool = combo_pools[combo_pool_pos];
8380 if (!pool.pick(cid, cs)) continue;
8381 }
8382 else if (draw_mode == dm_auto)
8383 {
8384 combo_auto const& cauto = combo_autos[combo_auto_pos];
8385 if (!cauto.valid())
8386 continue;
8387 if (!rclick && (cauto.containsCombo(targetcombo) && !ignored_combo))
8388 continue;
8389 if (rclick && cauto.getEraseCombo() == targetcombo)
8390 continue;
8391 }
8392
8393 if (draw_mode == dm_auto)
8394 draw_autocombo(pos, rclick);
8395 else
8396 Map.DoSetComboCommand(pos, only_cset ? -1 : cid, cs);
8397 }
8398 }
8399
8400 static void fill_flag(int32_t targetflag, ComboPosition start_pos, bool allow_diagonal)
8401 {
8402 mapscr* scr = Map.ScrMakeValid(start_pos, CurrentLayer);
8403 if (!scr)
8404 return;
8405
8406 int num_combos_width = 16 * Map.getViewSize();
8407 int num_combos_height = 11 * Map.getViewSize();
8408
8409 auto combo_positions = flood_filler(start_pos, allow_diagonal, [&](ComboPosition pos){
8410 if (pos.x < 0 || pos.y < 0 || pos.x >= num_combos_width || pos.y >= num_combos_height)
8411 return false;
8412
8413 mapscr* scr = Map.Scr(pos, CurrentLayer);
8414 if (!scr || !scr->is_valid())
8415 return false;
8416
8417 if (scr->sflag[pos.truncate()] != targetflag)
8418 return false;
8419
8420 return true;
8421 });
8422
8423 for (auto& pos : combo_positions)
8424 Map.DoSetFlagCommand(pos, Flag);
8425 }
8426
8427 static void fill2(int32_t targetcombo, int32_t targetcset, ComboPosition pos, int32_t dir, int32_t diagonal, bool only_cset)
8428 {
8429 mapscr* scr = Map.Scr(pos, CurrentLayer);
8430 if (!scr || !scr->is_valid())
8431 return;
8432
8433 int cid = scr->data[pos.truncate()];
8434 int cset = scr->cset[pos.truncate()];
8435
8436 if (!only_cset)
8437 {
8438 if (cid == targetcombo)
8439 return;
8440 }
8441
8442 if (cset == targetcset)
8443 return;
8444
8445 cid = Combo;
8446 int8_t cs = CSet;
8447 if(draw_mode == dm_cpool)
8448 {
8449 combo_pool const& pool = combo_pools[combo_pool_pos];
8450 if(!pool.pick(cid,cs)) return;
8451 }
8452
8453 Map.DoSetComboCommand(pos, only_cset ? -1 : cid, cs);
8454
8455 int num_combos_width = 16 * Map.getViewSize();
8456 int num_combos_height = 11 * Map.getViewSize();
8457
8458 if (pos.y > 0 && dir != down)
8459 fill2(targetcombo, targetcset, pos + ComboPosition{0, -1}, up, diagonal, only_cset);
8460 if (pos.y < num_combos_height-1 && dir != up)
8461 fill2(targetcombo, targetcset, pos + ComboPosition{0, 1}, down, diagonal, only_cset);
8462 if (pos.x > 0 && dir != right)
8463 fill2(targetcombo, targetcset, pos + ComboPosition{-1, 0}, left, diagonal, only_cset);
8464 if (pos.x < num_combos_width-1 && dir != left)
8465 fill2(targetcombo, targetcset, pos + ComboPosition{1, 0}, right, diagonal, only_cset);
8466
8467 if (diagonal == 1)
8468 {
8469 if (pos.y > 0 && pos.x > 0 && dir != r_down)
8470 fill2(targetcombo, targetcset, pos + ComboPosition{-1, -1}, l_up, diagonal, only_cset);
8471 if (pos.y < num_combos_height-1 && pos.x < num_combos_width-1 && dir != l_up)
8472 fill2(targetcombo, targetcset, pos + ComboPosition{1, 1}, r_down, diagonal, only_cset);
8473 if (pos.x > 0 && pos.y < num_combos_height-1 && dir != r_up)
8474 fill2(targetcombo, targetcset, pos + ComboPosition{-1, 1}, l_down, diagonal, only_cset);
8475 if (pos.x < num_combos_width-1 && pos.y > 0 && dir != l_down)
8476 fill2(targetcombo, targetcset, pos + ComboPosition{1, -1}, r_up, diagonal, only_cset);
8477 }
8478 }
8479
8480
8481 enum SnapMode
8482 {
8483 SNAP_NONE, SNAP_HALF, SNAP_WHOLE
8484 };
8485 static void snap_xy(int& x, int& y, SnapMode mode, roundType rounding, optional<int> max_x = nullopt, optional<int> max_y = nullopt)
8486 {
8487 if(mode == SNAP_NONE)
8488 {
8489 if(max_x) x = vbound(x,*max_x,0);
8490 if(max_y) y = vbound(y,*max_y,0);
8491 return;
8492 }
8493 int xoff = 0, yoff = 0;
8494 switch(rounding)
8495 {
8496 case ROUND_TO_0:
8497 rounding = ROUND_DOWN;
8498 break;
8499 case ROUND_AWAY_0:
8500 rounding = ROUND_UP;
8501 break;
8502 }
8503 int r = 0;
8504 switch(mode)
8505 {
8506 case SNAP_HALF:
8507 r = 8;
8508 break;
8509 case SNAP_WHOLE:
8510 r = 16;
8511 break;
8512 }
8513 assert(r > 0);
8514 // r must be a power of 2, for bitwise reasons
8515 switch(rounding)
8516 {
8517 case ROUND_DOWN:
8518 break;
8519 case ROUND_UP:
8520 xoff = ((x & (r-1)) ? r : 0);
8521 yoff = ((y & (r-1)) ? r : 0);
8522 break;
8523 case ROUND_NEAREST:
8524 xoff = ((x & (r-1)) >= (r/2) ? r : 0);
8525 yoff = ((y & (r-1)) >= (r/2) ? r : 0);
8526 break;
8527 }
8528 x = (x & ~(r-1)) + xoff;
8529 y = (y & ~(r-1)) + yoff;
8530 if(max_x && x >= *max_x) x = *max_x-r;
8531 else if(max_x && x < 0) x = 0;
8532 if(max_y && y >= *max_y) y = *max_y-r;
8533 else if(max_y && y < 0) y = 0;
8534 }
8535
8536 static void doxypos(byte &px2, byte &py2, int32_t color, SnapMode snap_mode,
8537 SnapMode shift_mode, bool immediately, int32_t cursoroffx,
8538 int32_t cursoroffy, int32_t iconw, int32_t iconh)
8539 {
8540 int32_t tempcb=ComboBrush;
8541 ComboBrush=0;
8542 MouseSprite::set(ZQM_POINT_BOX);
8543
8544 int viz_off_x = (active_visible_screen ? active_visible_screen->dx * 256 : 0);
8545 int viz_off_y = (active_visible_screen ? active_visible_screen->dy * 176 : 0);
8546
8547 int32_t oldpx=px2, oldpy=py2;
8548 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreen_single_scale):0);
8549 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreen_single_scale):0);
8550 showxypos_x=px2 + viz_off_x;
8551 showxypos_y=py2 + viz_off_y;
8552 showxypos_w=iconw;
8553 showxypos_h=iconh;
8554 showxypos_color=vc(color);
8555 showxypos_icon=!showxypos_dummy;
8556 bool canedit=false;
8557 bool done=false;
8558
8559 clear_tooltip();
8560
8561 while(!done && (!(gui_mouse_b()&2) || immediately))
8562 {
8563 if(!gui_mouse_b() || immediately)
8564 {
8565 canedit=true;
8566 }
8567
8568 // TODO: would be nice if these bounds were based on the individual screen.
8569 if(canedit && gui_mouse_b()==1 && isinRect(gui_mouse_x(),gui_mouse_y(),startxint,startyint,(startxint+(256*mapscreen_screenunit_scale)-1),(startyint+(176*mapscreen_screenunit_scale)-1)))
8570 {
8571 set_mouse_range(startxint,startyint,int32_t(startxint+(256*mapscreen_screenunit_scale)-1),int32_t(startyint+(176*mapscreen_screenunit_scale)-1));
8572
8573 double offx = 0, offy = 0;
8574 roundType rounding = ROUND_DOWN;
8575 if(DragCenterOfSquares)
8576 {
8577 offx -= iconw*mapscreen_single_scale/2;
8578 offy -= iconh*mapscreen_single_scale/2;
8579 rounding = ROUND_NEAREST;
8580 }
8581 int32_t x, y;
8582 do
8583 {
8584 x=int32_t((gui_mouse_x()-startxint+offx)/mapscreen_single_scale)-cursoroffx;
8585 y=int32_t((gui_mouse_y()-startyint+offy)/mapscreen_single_scale)-cursoroffy;
8586 showxypos_cursor_icon=true;
8587 showxypos_cursor_color = showxypos_color;
8588 auto _mode = (key[KEY_LSHIFT] || key[KEY_RSHIFT]) ? shift_mode : snap_mode;
8589 showxypos_cursor_x = x-viz_off_x;
8590 showxypos_cursor_y = y-viz_off_y;
8591 snap_xy(showxypos_cursor_x, showxypos_cursor_y, _mode, rounding, 256, 176);
8592 showxypos_cursor_x += viz_off_x;
8593 showxypos_cursor_y += viz_off_y;
8594 custom_vsync();
8595 refresh(rALL | rNOCURSOR);
8596 int32_t xpos[2], ypos[2];
8597 int32_t x1,y1,x2,y2;
8598
8599 char b1[200] = {0};
8600 char b2[200] = {0};
8601 if(showxypos_dummy)
8602 strcpy(b1, "DUMMY MEASURING");
8603 else sprintf(b1, "%d %d",oldpx,oldpy);
8604 sprintf(b2, "%d %d (%d %d)",x-viz_off_x,y-viz_off_y,showxypos_cursor_x-viz_off_x,showxypos_cursor_y-viz_off_y);
8605
8606 int len[2] = {text_length(font,b1),text_length(font,b2)};
8607
8608 if(is_compact)
8609 {
8610 xpos[0] = 4;
8611 ypos[0] = layer_panel.y - 21;
8612 xpos[1] = xpos[0];
8613 ypos[1] = ypos[0]+10;
8614 }
8615 else
8616 {
8617 xpos[0] = 450;
8618 ypos[0] = 405;
8619 xpos[1] = xpos[0];
8620 ypos[1] = ypos[0]+10;
8621 }
8622
8623 x1 = xpos[0];
8624 y1 = ypos[0];
8625 x2 = xpos[0];
8626 y2 = ypos[0];
8627 for(auto q = 0; q < 2; ++q)
8628 {
8629 if(xpos[q] < x1)
8630 x1 = xpos[q];
8631 if(ypos[q] < y1)
8632 y1 = ypos[q];
8633 if(ypos[q] > y2)
8634 y2 = ypos[q];
8635 if(xpos[q] + len[q] > x2)
8636 x2 = xpos[q] + len[q];
8637 }
8638 x1 -= 4;
8639 y1 -= 2;
8640 y2 += text_height(font)+2;
8641
8642 auto minx = zc_min(xpos[0],xpos[1]);
8643 auto miny = zc_min(ypos[0],ypos[1]);
8644 rectfill(screen,x1,y1,x2,y2,vc(0));
8645 textprintf_ex(screen,font,xpos[0],ypos[0],vc(15),vc(0),"%s",b1);
8646 textprintf_ex(screen,font,xpos[1],ypos[1],vc(15),vc(0),"%s",b2);
8647 update_hw_screen();
8648 }
8649 while(gui_mouse_b()==1);
8650
8651 if(gui_mouse_b()==0)
8652 {
8653 auto _mode = (key[KEY_LSHIFT] || key[KEY_RSHIFT]) ? shift_mode : snap_mode;
8654 int x2 = vbound(x-viz_off_x,0,255);
8655 int y2 = vbound(y-viz_off_y,0,175);
8656 snap_xy(x2, y2, _mode, rounding, 256, 176);
8657 px2=byte(x2);
8658 py2=byte(y2);
8659 }
8660
8661 set_mouse_range(0,0,zq_screen_w-1,zq_screen_h-1);
8662 done=true;
8663 }
8664
8665 if(keypressed())
8666 {
8667 switch(readkey()>>8)
8668 {
8669 case KEY_ESC:
8670 case KEY_ENTER:
8671 goto finished;
8672 }
8673 }
8674
8675 custom_vsync();
8676 refresh(rALL | rNOCURSOR);
8677 }
8678
8679 finished:
8680 MouseSprite::set(ZQM_NORMAL);
8681 refresh(rMAP+rMENU);
8682
8683 while(gui_mouse_b())
8684 {
8685 /* do nothing */
8686 rest(1);
8687 }
8688
8689 showxypos_x=-1000;
8690 showxypos_y=-1000;
8691 showxypos_color=-1000;
8692 showxypos_ffc=-1000;
8693 showxypos_icon=false;
8694 showxypos_cursor_x=-1000;
8695 showxypos_cursor_y=-1000;
8696 showxypos_cursor_icon=false;
8697 showxypos_cursor_color=-1000;
8698 showxypos_dummy=false;
8699
8700 if(px2!=oldpx||py2!=oldpy)
8701 {
8702 saved=false;
8703 }
8704
8705 ComboBrush=tempcb;
8706 }
8707 static void doxypos(byte &px2,byte &py2,int32_t color,SnapMode snap_mode, optional<SnapMode> shift_mode = nullopt)
8708 {
8709 doxypos(px2,py2,color,snap_mode,shift_mode ? *shift_mode : snap_mode,false,0,0,16,16);
8710 }
8711
8712 bool placing_flags = false;
8713 void doflags()
8714 {
8715 placing_flags = true;
8716 int of=Flags;
8717 Flags=cFLAGS;
8718 refresh(rMAP | rNOCURSOR);
8719
8720 bool canedit=false;
8721 bool didShift = false;
8722 int tFlag = Flag;
8723 while(!(gui_mouse_b()&2) && !handle_close_btn_quit())
8724 {
8725 int x=gui_mouse_x();
8726 int y=gui_mouse_y();
8727 double startx=mapscreen_x+(showedges?(16*mapscreen_single_scale):0);
8728 double starty=mapscreen_y+(showedges?(16*mapscreen_single_scale):0);
8729 int startxint=mapscreen_x+(showedges?int(16*mapscreen_single_scale):0);
8730 int startyint=mapscreen_y+(showedges?int(16*mapscreen_single_scale):0);
8731 int cx=(x-startxint)/int(16*mapscreen_single_scale);
8732 int cy=(y-startyint)/int(16*mapscreen_single_scale);
8733 ComboPosition combo_pos = {cx, cy};
8734 int c = combo_pos.truncate();
8735
8736 if(!gui_mouse_b())
8737 canedit=true;
8738 bool shift = key[KEY_LSHIFT] || key[KEY_RSHIFT];
8739
8740 if(canedit && gui_mouse_b()==1 && isinRect(x,y,startxint,startyint,int(startx+(256*mapscreen_screenunit_scale)-1),int(starty+(176*mapscreen_screenunit_scale)-1)))
8741 {
8742 mapscr* cur_scr = Map.Scr(combo_pos, CurrentLayer);
8743 if (!cur_scr) continue;
8744
8745 Map.setCurrScr(Map.getScreenForPosition(combo_pos));
8746
8747 if(key[KEY_ALT]||key[KEY_ALTGR])
8748 Flag = cur_scr->sflag[c];
8749 else
8750 {
8751 saved=false;
8752 int tflag = Flag;
8753 if(shift)
8754 Flag = mfNONE;
8755 if(CurrentLayer!=0)
8756 {
8757 // Notify if they are using a flag that doesn't work on this layer.
8758 if(!skipLayerWarning && ((Flag >= mfTRAP_H && Flag < mfPUSHD) || (Flag == mfFAIRY) || (Flag == mfMAGICFAIRY)
8759 || (Flag == mfALLFAIRY) || (Flag == mfRAFT) || (Flag == mfRAFT_BRANCH)
8760 || (Flag == mfDIVE_ITEM) || (Flag == mfARMOS_SECRET) || (Flag == mfNOENEMY)
8761 || (Flag == mfZELDA)))
8762 {
8763 InfoDialog("Notice","You are currently working on layer "
8764 +to_string(CurrentLayer)
8765 +". This combo flag does not function on layers above '0'.").show();
8766 }
8767 if(!skipLayerWarning && CurrentLayer > 2 &&
8768 ((Flag == mfBLOCKHOLE) || (Flag >= mfPUSHD && Flag < mfNOBLOCKS)
8769 || (Flag == mfPUSHUD) || (Flag == mfPUSH4)))
8770 {
8771 InfoDialog("Notice","You are currently working on layer "
8772 +to_string(CurrentLayer)
8773 +". This combo flag does not function on layers above '2'.").show();
8774 }
8775 }
8776 if(CHECK_CTRL_CMD)
8777 {
8778 switch(fill_type)
8779 {
8780 case 0:
8781 flood_flag();
8782 break;
8783
8784 case 1:
8785 case 3:
8786 fill_4_flag();
8787 break;
8788
8789 case 2:
8790 case 4:
8791 fill_8_flag();
8792 break;
8793 }
8794 }
8795 else
8796 {
8797 Map.DoSetFlagCommand(combo_pos, Flag);
8798 }
8799 Flag = tflag;
8800 }
8801 }
8802
8803 if(mouse_z)
8804 {
8805 for(int i=0; i<abs(mouse_z); ++i)
8806 {
8807 if(mouse_z>0)
8808 onIncreaseFlag();
8809 else
8810 onDecreaseFlag();
8811 }
8812
8813 position_mouse_z(0);
8814 }
8815
8816 if(keypressed())
8817 {
8818 int k = readkey();
8819 switch(k>>8)
8820 {
8821 case KEY_ESC:
8822 case KEY_ENTER:
8823 goto finished;
8824 }
8825 object_message(dialogs+1, MSG_XCHAR, k);
8826 Flags=cFLAGS;
8827 }
8828
8829 MouseSprite::set(ZQM_FLAG_0+(shift?0:Flag%16));
8830
8831 refresh(rALL | rCLEAR | rNOCURSOR);
8832 custom_vsync();
8833 }
8834
8835 finished:
8836 Flags=of;
8837 placing_flags = false;
8838 MouseSprite::set(ZQM_NORMAL);
8839 refresh(rMAP+rMENU);
8840
8841 while(gui_mouse_b())
8842 {
8843 /* do nothing */
8844 rest(1);
8845 }
8846 }
8847
8848 // Drag FFCs around
8849 static void moveffc(int i, int cx, int cy)
8850 {
8851 mapscr* scr = active_visible_screen->scr;
8852 int screen = active_visible_screen->screen;
8853
8854 int32_t ffx = vbound(scr->ffcs[i].x.getFloor(),0,240);
8855 int32_t ffy = vbound(scr->ffcs[i].y.getFloor(),0,160);
8856 int32_t offx = ffx, offy = ffy;
8857 showxypos_ffc = i;
8858 doxypos((byte&)ffx,(byte&)ffy,15,SNAP_HALF,SNAP_NONE,true,0,0,(scr->ffTileWidth(i)*16),(scr->ffTileHeight(i)*16));
8859 if(ffx > 240) ffx = 240;
8860 if(ffy > 160) ffy = 160;
8861 if((ffx != offx) || (ffy != offy))
8862 {
8863 auto set_ffc_data = set_ffc_command::create_data(scr->ffcs[i]);
8864 set_ffc_data.x = ffx;
8865 set_ffc_data.y = ffy;
8866 Map.DoSetFFCCommand(Map.getCurrMap(), screen, i, set_ffc_data);
8867 saved = false;
8868 }
8869 }
8870
8871 void set_brush_width(int32_t width);
8872 void set_brush_height(int32_t height);
8873
8874 int32_t set_brush_width_1()
8875 {
8876 set_brush_width(1);
8877 return D_O_K;
8878 }
8879 int32_t set_brush_width_2()
8880 {
8881 set_brush_width(2);
8882 return D_O_K;
8883 }
8884 int32_t set_brush_width_3()
8885 {
8886 set_brush_width(3);
8887 return D_O_K;
8888 }
8889 int32_t set_brush_width_4()
8890 {
8891 set_brush_width(4);
8892 return D_O_K;
8893 }
8894 int32_t set_brush_width_5()
8895 {
8896 set_brush_width(5);
8897 return D_O_K;
8898 }
8899 int32_t set_brush_width_6()
8900 {
8901 set_brush_width(6);
8902 return D_O_K;
8903 }
8904 int32_t set_brush_width_7()
8905 {
8906 set_brush_width(7);
8907 return D_O_K;
8908 }
8909 int32_t set_brush_width_8()
8910 {
8911 set_brush_width(8);
8912 return D_O_K;
8913 }
8914 int32_t set_brush_width_9()
8915 {
8916 set_brush_width(9);
8917 return D_O_K;
8918 }
8919 int32_t set_brush_width_10()
8920 {
8921 set_brush_width(10);
8922 return D_O_K;
8923 }
8924 int32_t set_brush_width_11()
8925 {
8926 set_brush_width(11);
8927 return D_O_K;
8928 }
8929 int32_t set_brush_width_12()
8930 {
8931 set_brush_width(12);
8932 return D_O_K;
8933 }
8934 int32_t set_brush_width_13()
8935 {
8936 set_brush_width(13);
8937 return D_O_K;
8938 }
8939 int32_t set_brush_width_14()
8940 {
8941 set_brush_width(14);
8942 return D_O_K;
8943 }
8944 int32_t set_brush_width_15()
8945 {
8946 set_brush_width(15);
8947 return D_O_K;
8948 }
8949 int32_t set_brush_width_16()
8950 {
8951 set_brush_width(16);
8952 return D_O_K;
8953 }
8954
8955 int32_t set_brush_height_1()
8956 {
8957 set_brush_height(1);
8958 return D_O_K;
8959 }
8960 int32_t set_brush_height_2()
8961 {
8962 set_brush_height(2);
8963 return D_O_K;
8964 }
8965 int32_t set_brush_height_3()
8966 {
8967 set_brush_height(3);
8968 return D_O_K;
8969 }
8970 int32_t set_brush_height_4()
8971 {
8972 set_brush_height(4);
8973 return D_O_K;
8974 }
8975 int32_t set_brush_height_5()
8976 {
8977 set_brush_height(5);
8978 return D_O_K;
8979 }
8980 int32_t set_brush_height_6()
8981 {
8982 set_brush_height(6);
8983 return D_O_K;
8984 }
8985 int32_t set_brush_height_7()
8986 {
8987 set_brush_height(7);
8988 return D_O_K;
8989 }
8990 int32_t set_brush_height_8()
8991 {
8992 set_brush_height(8);
8993 return D_O_K;
8994 }
8995 int32_t set_brush_height_9()
8996 {
8997 set_brush_height(9);
8998 return D_O_K;
8999 }
9000 int32_t set_brush_height_10()
9001 {
9002 set_brush_height(10);
9003 return D_O_K;
9004 }
9005 int32_t set_brush_height_11()
9006 {
9007 set_brush_height(11);
9008 return D_O_K;
9009 }
9010
9011
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu brush_width_menu
9012 204 {
9013
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "1", set_brush_width_1 },
9014
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2", set_brush_width_2 },
9015
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "3", set_brush_width_3 },
9016
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "4", set_brush_width_4 },
9017
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "5", set_brush_width_5 },
9018
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "6", set_brush_width_6 },
9019
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "7", set_brush_width_7 },
9020
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "8", set_brush_width_8 },
9021
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "9", set_brush_width_9 },
9022
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "10", set_brush_width_10 },
9023
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "11", set_brush_width_11 },
9024
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "12", set_brush_width_12 },
9025
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "13", set_brush_width_13 },
9026
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "14", set_brush_width_14 },
9027
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "15", set_brush_width_15 },
9028
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "16", set_brush_width_16 },
9029 };
9030
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu brush_height_menu
9031 144 {
9032
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "1", set_brush_height_1 },
9033
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2", set_brush_height_2 },
9034
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "3", set_brush_height_3 },
9035
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "4", set_brush_height_4 },
9036
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "5", set_brush_height_5 },
9037
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "6", set_brush_height_6 },
9038
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "7", set_brush_height_7 },
9039
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "8", set_brush_height_8 },
9040
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "9", set_brush_height_9 },
9041
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "10", set_brush_height_10 },
9042
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "11", set_brush_height_11 },
9043 };
9044
9045 int toggle_autobrush();
9046 int toggle_combobrush();
9047 int toggle_floatbrush();
9048 enum
9049 {
9050 MENUID_BRUSH_AUTOBRUSH,
9051 MENUID_BRUSH_WIDTH,
9052 MENUID_BRUSH_HEIGHT,
9053 MENUID_BRUSH_COMBOBRUSH,
9054 MENUID_BRUSH_FLOATBRUSH,
9055 };
9056
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu brush_menu
9057 72 {
9058
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "AutoBrush", toggle_autobrush, MENUID_BRUSH_AUTOBRUSH },
9059
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Brush Width ", &brush_width_menu, MENUID_BRUSH_WIDTH },
9060
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Brush Height ", &brush_height_menu, MENUID_BRUSH_HEIGHT },
9061
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "ComboBrush", toggle_combobrush, MENUID_BRUSH_COMBOBRUSH },
9062
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "FloatBrush", toggle_floatbrush, MENUID_BRUSH_FLOATBRUSH },
9063 };
9064 int toggle_autobrush()
9065 {
9066 AutoBrush = AutoBrush ? 0 : 1;
9067 BrushWidth = BrushHeight = 1;
9068 brush_menu.select_uid(MENUID_BRUSH_AUTOBRUSH, AutoBrush);
9069 brush_menu.disable_uid(MENUID_BRUSH_WIDTH, AutoBrush);
9070 brush_menu.disable_uid(MENUID_BRUSH_HEIGHT, AutoBrush);
9071 zc_set_config("zquest","autobrush",AutoBrush);
9072 return D_O_K;
9073 }
9074 int toggle_combobrush()
9075 {
9076 ComboBrush = ComboBrush ? 0 : 1;
9077 brush_menu.select_uid(MENUID_BRUSH_COMBOBRUSH, ComboBrush);
9078 zc_set_config("zquest","combo_brush",ComboBrush);
9079 return D_O_K;
9080 }
9081 int toggle_floatbrush()
9082 {
9083 FloatBrush = FloatBrush ? 0 : 1;
9084 brush_menu.select_uid(MENUID_BRUSH_FLOATBRUSH, FloatBrush);
9085 zc_set_config("zquest","float_brush",FloatBrush);
9086 return D_O_K;
9087 }
9088
9089 int32_t set_flood();
9090 int32_t set_fill_4();
9091 int32_t set_fill_8();
9092 int32_t set_fill2_4();
9093 int32_t set_fill2_8();
9094
9095 // Sets every combo.
9096 void flood()
9097 {
9098 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9099 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9100 if (!scr || !scr->is_valid())
9101 return;
9102
9103 saved=false;
9104
9105 bool include_combos = !(key[KEY_LSHIFT]||key[KEY_RSHIFT]);
9106
9107 int num_combos_width = 16 * Map.getViewSize();
9108 int num_combos_height = 11 * Map.getViewSize();
9109
9110 Map.StartListCommand();
9111 for (int x = 0; x < num_combos_width; x++)
9112 {
9113 for (int y = 0; y < num_combos_height; y++)
9114 {
9115 ComboPosition pos = {x, y};
9116 mapscr* scr = Map.Scr(pos, CurrentLayer);
9117 if (!scr || !scr->is_valid())
9118 continue;
9119
9120 if (draw_mode == dm_auto)
9121 draw_autocombo(pos, gui_mouse_b() & 2);
9122 else
9123 Map.DoSetComboCommand(pos, include_combos ? Combo : -1, CSet);
9124 }
9125 }
9126 Map.FinishListCommand();
9127
9128 refresh(rMAP+rSCRMAP);
9129 }
9130 void flood_flag()
9131 {
9132 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9133 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9134 if (!scr || !scr->is_valid())
9135 return;
9136
9137 saved=false;
9138
9139 int num_combos_width = 16 * Map.getViewSize();
9140 int num_combos_height = 11 * Map.getViewSize();
9141
9142 Map.StartListCommand();
9143 for (int x = 0; x < num_combos_width; x++)
9144 {
9145 for (int y = 0; y < num_combos_height; y++)
9146 {
9147 ComboPosition pos = {x, y};
9148 mapscr* scr = Map.Scr(pos, CurrentLayer);
9149 if (!scr || !scr->is_valid())
9150 continue;
9151
9152 Map.DoSetFlagCommand(pos, Flag);
9153 }
9154 }
9155 Map.FinishListCommand();
9156
9157 refresh(rMAP+rSCRMAP);
9158 }
9159
9160 void fill_4()
9161 {
9162 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9163 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9164 if (!scr)
9165 return;
9166
9167 int c = pos.truncate();
9168 if (draw_mode == dm_cpool || draw_mode == dm_auto
9169 || (scr->cset[c]!=CSet || (scr->data[c]!=Combo && !(key[KEY_LSHIFT]||key[KEY_RSHIFT]))))
9170 {
9171 saved=false;
9172
9173 Map.StartListCommand();
9174 if (draw_mode == dm_auto && (combo_autos[combo_auto_pos].getType() == AUTOCOMBO_FENCE ||
9175 combo_autos[combo_auto_pos].getType() == AUTOCOMBO_Z4))
9176 {
9177 draw_autocombo_command(pos);
9178 }
9179 else
9180 {
9181 bool allow_diagonal = false;
9182 fill(scr->data[c], scr->cset[c], pos, allow_diagonal, (key[KEY_LSHIFT] || key[KEY_RSHIFT]));
9183 }
9184 Map.FinishListCommand();
9185 refresh(rMAP+rSCRMAP);
9186 }
9187 }
9188 void fill_4_flag()
9189 {
9190 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9191 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9192 if (!scr)
9193 return;
9194
9195 int flag = scr->sflag[pos.truncate()];
9196 if (flag != Flag)
9197 {
9198 saved=false;
9199
9200 Map.StartListCommand();
9201 bool allow_diagonal = false;
9202 fill_flag(flag, pos, allow_diagonal);
9203 Map.FinishListCommand();
9204 refresh(rMAP+rSCRMAP);
9205 }
9206 }
9207 void fill_8()
9208 {
9209 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9210 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9211 if (!scr)
9212 return;
9213
9214 int c = pos.truncate();
9215 if (draw_mode == dm_cpool || draw_mode == dm_auto
9216 || (scr->cset[c] != CSet ||
9217 (scr->data[c] != Combo &&
9218 !(key[KEY_LSHIFT]||key[KEY_RSHIFT]))))
9219 {
9220 saved=false;
9221
9222 Map.StartListCommand();
9223 bool allow_diagonal = true;
9224 fill(scr->data[c], scr->cset[c], pos, allow_diagonal, (key[KEY_LSHIFT]||key[KEY_RSHIFT]));
9225 Map.FinishListCommand();
9226
9227 refresh(rMAP+rSCRMAP);
9228 }
9229 }
9230 void fill_8_flag()
9231 {
9232 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9233 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9234 if (!scr)
9235 return;
9236
9237 int flag = scr->sflag[pos.truncate()];
9238 if (flag != Flag)
9239 {
9240 saved=false;
9241
9242 Map.StartListCommand();
9243 bool allow_diagonal = true;
9244 fill_flag(flag, pos, allow_diagonal);
9245 Map.FinishListCommand();
9246 refresh(rMAP+rSCRMAP);
9247 }
9248 }
9249
9250 void fill2_4()
9251 {
9252 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9253 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9254 if (!scr)
9255 return;
9256
9257 saved=false;
9258
9259 Map.StartListCommand();
9260 fill2(Combo, CSet, pos, 255, 0, (key[KEY_LSHIFT]||key[KEY_RSHIFT]));
9261 Map.FinishListCommand();
9262 refresh(rMAP+rSCRMAP);
9263 }
9264
9265 void fill2_8()
9266 {
9267 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9268 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9269 if (!scr)
9270 return;
9271
9272 saved=false;
9273
9274 Map.StartListCommand();
9275 fill2(Combo, CSet, pos, 255, 1, (key[KEY_LSHIFT]||key[KEY_RSHIFT]));
9276 Map.FinishListCommand();
9277
9278 refresh(rMAP+rSCRMAP);
9279 }
9280
9281
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu fill_menu
9282 72 {
9283
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Flood", set_flood, 0 },
9284
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Fill (4-way)", set_fill_4, 1 },
9285
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Fill (8-way)", set_fill_8, 2 },
9286
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Fill2 (4-way)", set_fill2_4, 3 },
9287
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Fill2 (8-way)", set_fill2_8, 4 },
9288 };
9289 void set_filltype(int ty)
9290 {
9291 fill_type = ty;
9292 fill_menu.select_only_uid(ty);
9293 }
9294
9295 int32_t set_flood()
9296 {
9297 set_filltype(0);
9298 return D_O_K;
9299 }
9300
9301 int32_t set_fill_4()
9302 {
9303 set_filltype(1);
9304 return D_O_K;
9305 }
9306
9307 int32_t set_fill_8()
9308 {
9309 set_filltype(2);
9310 return D_O_K;
9311 }
9312
9313 int32_t set_fill2_4()
9314 {
9315 set_filltype(3);
9316 return D_O_K;
9317 }
9318
9319 int32_t set_fill2_8()
9320 {
9321 set_filltype(4);
9322 return D_O_K;
9323 }
9324
9325 int32_t draw_block_1_2()
9326 {
9327 draw_block(mouse_combo_pos,1,2);
9328 return D_O_K;
9329 }
9330
9331 int32_t draw_block_2_1()
9332 {
9333 draw_block(mouse_combo_pos,2,1);
9334 return D_O_K;
9335 }
9336
9337 int32_t draw_block_2_2()
9338 {
9339 draw_block(mouse_combo_pos,2,2);
9340 return D_O_K;
9341 }
9342
9343 int32_t draw_block_2_3()
9344 {
9345 draw_block(mouse_combo_pos,2,3);
9346 return D_O_K;
9347 }
9348
9349 int32_t draw_block_3_2()
9350 {
9351 draw_block(mouse_combo_pos,3,2);
9352 return D_O_K;
9353 }
9354
9355 int32_t draw_block_3_3()
9356 {
9357 draw_block(mouse_combo_pos,3,3);
9358 return D_O_K;
9359 }
9360
9361 int32_t draw_block_4_2()
9362 {
9363 draw_block(mouse_combo_pos,4,2);
9364 return D_O_K;
9365 }
9366
9367 int32_t draw_block_4_4()
9368 {
9369 draw_block(mouse_combo_pos,4,4);
9370 return D_O_K;
9371 }
9372
9373
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu draw_block_menu
9374 108 {
9375
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "1x2", draw_block_1_2 },
9376
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2x1", draw_block_2_1 },
9377
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2x2", draw_block_2_2 },
9378
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2x3", draw_block_2_3 },
9379
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "3x2", draw_block_3_2 },
9380
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "3x3", draw_block_3_3 },
9381
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "4x2", draw_block_4_2 },
9382
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "4x4", draw_block_4_4 },
9383 };
9384
9385
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu paste_screen_menu
9386 60 {
9387
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste", onPaste },
9388
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste All", onPasteAll },
9389
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste to All", onPasteToAll },
9390
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste All to All", onPasteAllToAll },
9391 };
9392
9393 int32_t scrollto_cmb(int32_t cid)
9394 {
9395 auto& sqr = combolist[current_combolist];
9396 int32_t res = vbound(cid-(sqr.w*sqr.h/2),0,MAXCOMBOS-(sqr.w*sqr.h));
9397 res -= res%sqr.w;
9398 return res;
9399 }
9400 int32_t scrollto_alias(int32_t alid)
9401 {
9402 auto& sqr = comboaliaslist[current_comboalist];
9403 int32_t res = vbound(alid-(sqr.w*sqr.h/2),0,MAXCOMBOALIASES-(sqr.w*sqr.h));
9404 res -= res%sqr.w;
9405 return res;
9406 }
9407
9408 int32_t scrollto_cpool(int32_t cpid)
9409 {
9410 auto& sqr = comboaliaslist[current_cpoollist];
9411 int32_t res = vbound(cpid-(sqr.w*sqr.h/2),0,MAXCOMBOPOOLS-(sqr.w*sqr.h));
9412 res -= res%sqr.w;
9413 return res;
9414 }
9415
9416 int32_t scrollto_cauto(int32_t caid)
9417 {
9418 auto& sqr = comboaliaslist[current_cautolist];
9419 int32_t res = vbound(caid - (sqr.w * sqr.h / 2), 0, MAXCOMBOPOOLS - (sqr.w * sqr.h));
9420 res -= res % sqr.w;
9421 return res;
9422 }
9423
9424 void add_favorite_combo_block(int32_t favind, int32_t cid, bool force)
9425 {
9426 int32_t w = vbound(BrushWidth, 1, 4);
9427 int32_t h = vbound(BrushHeight, 1, 7);
9428 for (int32_t xi = 0; xi < w; ++xi)
9429 {
9430 for (int32_t yi = 0; yi < h; ++yi)
9431 {
9432 int32_t cx = cid % 4;
9433 int32_t cy = cid / 4;
9434 int32_t cc = (cy + yi) * 4 + cx + xi;
9435 int32_t fx = favind % FAVORITECOMBO_PER_ROW;
9436 int32_t fy = favind / FAVORITECOMBO_PER_ROW;
9437 int32_t fc = (fy + yi) * FAVORITECOMBO_PER_ROW + fx + xi + FAVORITECOMBO_PER_PAGE * FavoriteComboPage;
9438
9439 if (cx + xi < 4 && cc < MAXCOMBOS && fx + xi < FAVORITECOMBO_PER_ROW && fy + yi < FAVORITECOMBO_PER_COLUMN)
9440 {
9441 if (favorite_combos[fc] < 0 || force)
9442 {
9443 favorite_combo_modes[fc] = dm_normal;
9444 favorite_combos[fc] = cc;
9445 }
9446 }
9447 }
9448 }
9449 }
9450
9451 void onRCSelectCombo(int32_t c)
9452 {
9453 int32_t drawmap, drawscr;
9454
9455 if(CurrentLayer==0)
9456 {
9457 drawmap=Map.getCurrMap();
9458 drawscr=Map.getCurrScr();
9459 }
9460 else
9461 {
9462 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9463 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9464 }
9465 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9466 if(!draw_mapscr) return;
9467
9468 Combo=draw_mapscr->data[c];
9469 if(AutoBrush)
9470 BrushWidth = BrushHeight = 1;
9471 }
9472
9473 void onRCScrollToombo(int32_t c)
9474 {
9475 int32_t drawmap, drawscr;
9476
9477 if(CurrentLayer==0)
9478 {
9479 drawmap=Map.getCurrMap();
9480 drawscr=Map.getCurrScr();
9481 }
9482 else
9483 {
9484 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9485 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9486 }
9487 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9488 if(!draw_mapscr) return;
9489
9490 auto& sqr = combolist[current_combolist];
9491 First[current_combolist]=scrollto_cmb(draw_mapscr->data[c]);
9492 }
9493
9494 enum
9495 {
9496 MENUID_RCSCREEN_PASTE,
9497 MENUID_RCSCREEN_ADVPASTE,
9498 MENUID_RCSCREEN_SPECPASTE,
9499 };
9500
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu rc_menu_screen
9501 60 {
9502
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Copy Screen", onCopy },
9503
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste Screen", &paste_screen_menu, MENUID_RCSCREEN_PASTE },
9504
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "...Advanced Paste", &paste_menu, MENUID_RCSCREEN_ADVPASTE },
9505
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "...Special Paste", &paste_item_menu, MENUID_RCSCREEN_SPECPASTE },
9506 };
9507
9508 void call_options_dlg();
9509 int32_t onOptions()
9510 {
9511 call_options_dlg();
9512 brush_menu.select_uid(MENUID_BRUSH_AUTOBRUSH, AutoBrush);
9513 brush_menu.disable_uid(MENUID_BRUSH_WIDTH, AutoBrush);
9514 brush_menu.disable_uid(MENUID_BRUSH_HEIGHT, AutoBrush);
9515 brush_menu.select_uid(MENUID_BRUSH_FLOATBRUSH, FloatBrush);
9516 brush_menu.select_uid(MENUID_BRUSH_COMBOBRUSH, ComboBrush);
9517 return D_O_K;
9518 }
9519
9520 void follow_twarp(int warpindex)
9521 {
9522 if(warpindex >= 4)
9523 {
9524 InfoDialog("Random Tile Warp",
9525 "This is a random tile warp combo, so it chooses"
9526 " randomly between the screen's four Tile Warps.").show();
9527 warpindex=zc_oldrand()&3;
9528 }
9529
9530 int32_t tm = Map.getCurrMap();
9531 int32_t ts = Map.getCurrScr();
9532 int32_t wt = Map.CurrScr()->tilewarptype[warpindex];
9533
9534 if(wt==wtCAVE || wt==wtNOWARP)
9535 {
9536 char buf[56];
9537 InfoDialog(warptype_string[wt],fmt::format("This screen's Tile Warp {} is set to {}, so it doesn't lead to another screen.",'A'+warpindex,warptype_string[wt]));
9538 return;
9539 }
9540
9541 Map.dowarp(0,warpindex);
9542
9543 if(ts!=Map.getCurrScr() || tm!=Map.getCurrMap())
9544 {
9545 FlashWarpSquare = (TheMaps[tm*MAPSCRS+ts].warpreturnc>>(warpindex*2))&3;
9546 FlashWarpClk = 32;
9547 }
9548 }
9549 void edit_twarp(int warpindex)
9550 {
9551 if(warpindex>=4)
9552 {
9553 InfoDialog("Random Tile Warp",
9554 "This is a random tile warp combo, so it chooses"
9555 " randomly between the screen's four Tile Warps.").show();
9556 warpindex=zc_oldrand()&3;
9557 }
9558
9559 if(warpindex > -1 && warpindex < 4)
9560 onTileWarpIndex(warpindex);
9561 }
9562
9563 int toggle_linked_scrolling()
9564 {
9565 LinkedScroll = LinkedScroll ? 0 : 1;
9566 zc_set_config("zquest","linked_comboscroll",LinkedScroll);
9567 return D_O_K;
9568 }
9569 void on_scroll_cpane()
9570 {
9571 switch (draw_mode)
9572 {
9573 case dm_alias:
9574 combo_alistpos[current_comboalist] = scrollto_alias(combo_apos);
9575 break;
9576 case dm_cpool:
9577 combo_pool_listpos[current_cpoollist] = scrollto_cpool(combo_pool_pos);
9578 break;
9579 case dm_auto:
9580 combo_auto_listpos[current_cautolist] = scrollto_cauto(combo_auto_pos);
9581 break;
9582 default:
9583 First[current_combolist] = scrollto_cmb(Combo);
9584 break;
9585 }
9586 }
9587 void on_edit_cpane()
9588 {
9589 switch (draw_mode)
9590 {
9591 case dm_alias:
9592 onEditComboAlias();
9593 break;
9594 case dm_cpool:
9595 onEditComboPool();
9596 break;
9597 case dm_auto:
9598 onEditAutoCombo();
9599 break;
9600 default:
9601 reset_combo_animations();
9602 reset_combo_animations2();
9603 edit_combo(Combo, true, CSet);
9604 setup_combo_animations();
9605 setup_combo_animations2();
9606 break;
9607 }
9608 }
9609 void on_cpane_page()
9610 {
9611 switch(draw_mode)
9612 {
9613 case dm_normal:
9614 combo_screen(Combo>>8,Combo);
9615 break;
9616 case dm_alias:
9617 call_alias_pages(combo_apos);
9618 break;
9619 case dm_auto:
9620 call_autoc_pages(combo_auto_pos);
9621 break;
9622 case dm_cpool:
9623 call_cpool_pages(combo_pool_pos);
9624 break;
9625 }
9626 }
9627 void open_cpane_tilepage()
9628 {
9629 onGotoTiles(combobuf[Combo].o_tile);
9630 }
9631 static int _clicked_fav = 0;
9632 void fav_rc_remove()
9633 {
9634 favorite_combo_modes[_clicked_fav] = dm_normal;
9635 favorite_combos[_clicked_fav] = -1;
9636 saved = false;
9637 }
9638 void popup_favorites_rc(int f, int x, int y)
9639 {
9640 _clicked_fav = f;
9641 string type;
9642 switch (draw_mode)
9643 {
9644 case dm_alias:
9645 type = "Alias";
9646 break;
9647 case dm_cpool:
9648 type = "Pool";
9649 break;
9650 case dm_auto:
9651 type = "Autocombo";
9652 break;
9653 case dm_normal:
9654 type = "Combo";
9655 break;
9656 default: return;
9657 }
9658 NewMenu rcmenu
9659 {
9660 { fmt::format("Scroll to {}", type), on_scroll_cpane },
9661 { fmt::format("Edit {}", type), on_edit_cpane },
9662 { fmt::format("Open {} Page", type), on_cpane_page },
9663 { fmt::format("Remove Fav {}", type), fav_rc_remove },
9664 };
9665 switch (draw_mode)
9666 {
9667 case dm_normal:
9668 rcmenu.add({
9669 {},
9670 { "Open Tile Page", open_cpane_tilepage },
9671 });
9672 break;
9673 }
9674 rcmenu.pop(x, y);
9675 }
9676 void popup_cpane_rc(int x, int y)
9677 {
9678 string type;
9679 switch (draw_mode)
9680 {
9681 case dm_alias:
9682 type = "Alias";
9683 break;
9684 case dm_cpool:
9685 type = "Pool";
9686 break;
9687 case dm_auto:
9688 type = "Autocombo";
9689 break;
9690 case dm_normal:
9691 type = "Combo";
9692 break;
9693 default: return;
9694 }
9695 NewMenu rcmenu;
9696 switch(draw_mode)
9697 {
9698 case dm_normal:
9699 rcmenu.add({
9700 { fmt::format("Edit {}", type), on_edit_cpane },
9701 { fmt::format("Open {} Page", type), on_cpane_page },
9702 { "Open Tile Page", open_cpane_tilepage },
9703 { "Combo Locations", onComboLocationReport },
9704 {},
9705 { "Scroll to Page...", onGotoPage },
9706 { "Linked Scrolling", toggle_linked_scrolling, nullopt, LinkedScroll ? MFL_SEL : 0 },
9707 });
9708 break;
9709 case dm_alias:
9710 case dm_cpool:
9711 case dm_auto:
9712 rcmenu.add({
9713 { fmt::format("Edit {}", type), on_edit_cpane },
9714 { fmt::format("Open {} Page", type), on_cpane_page },
9715 {},
9716 { "Scroll to Page...", onGotoPage },
9717 { "Linked Scrolling", toggle_linked_scrolling, nullopt, LinkedScroll ? MFL_SEL : 0 },
9718 });
9719 break;
9720 }
9721 rcmenu.pop(x, y);
9722 }
9723
9724 void set_brush_width(int32_t width)
9725 {
9726 BrushWidth = width;
9727 for(int q = 0; q < brush_width_menu.size(); ++q)
9728 brush_width_menu.at(q)->select(q==BrushWidth-1);
9729 refresh(rALL);
9730 }
9731
9732 void set_brush_height(int32_t height)
9733 {
9734 BrushHeight = height;
9735 for(int q = 0; q < brush_height_menu.size(); ++q)
9736 brush_height_menu.at(q)->select(q==BrushHeight-1);
9737 refresh(rALL);
9738 }
9739
9740 1 void restore_mouse()
9741 {
9742 1 ComboBrushPause=1;
9743 1 MouseSprite::set(ZQM_NORMAL);
9744 1 }
9745
9746 static int32_t comboa_cnt=0;
9747 static int32_t combop_cnt=0;
9748 static int32_t layer_cnt=0;
9749
9750 static char paste_ffc_menu_text[21];
9751 static char paste_ffc_menu_text2[21];
9752 static char follow_warp_menu_text[21];
9753 static char follow_warp_menu_text2[21];
9754
9755 static int fake_mouse_b(){return 0;}
9756 static int (*mouseb_proc)();
9757 static bool killed_mouse = false;
9758 void zq_killmouse()
9759 {
9760 if(killed_mouse) return;
9761 mouseb_proc = gui_mouse_b;
9762 gui_mouse_b = fake_mouse_b;
9763 killed_mouse = true;
9764 }
9765 void zq_restoremouse()
9766 {
9767 if(!killed_mouse) return;
9768 gui_mouse_b = mouseb_proc;
9769 killed_mouse = false;
9770 }
9771
9772
9773 void domouse()
9774 {
9775 static int mouse_down = 0;
9776 static int32_t scrolldelay = 0;
9777 auto mousexy = zc_get_mouse();
9778 auto x = mousexy.first;
9779 auto y = mousexy.second;
9780 double startx=mapscreen_x+(showedges?(16*mapscreen_single_scale):0);
9781 double starty=mapscreen_y+(showedges?(16*mapscreen_single_scale):0);
9782 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreen_single_scale):0);
9783 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreen_single_scale):0);
9784 int32_t cx=(x-startx)/(16*mapscreen_single_scale);
9785 int32_t cy=(y-starty)/(16*mapscreen_single_scale);
9786 ComboPosition combo_pos = {cx, cy};
9787
9788 if (draw_mode == dm_auto)
9789 {
9790 if (combo_pos != mouse_combo_pos)
9791 combobrushoverride = get_autocombo_floating_cid(combo_pos, false);
9792 }
9793 else
9794 combobrushoverride = -1;
9795
9796 mouse_combo_pos = combo_pos;
9797 update_combobrush();
9798
9799 ++scrolldelay;
9800
9801 bool x_on_list = false;
9802 for(auto q = 0; q < num_combo_cols; ++q)
9803 {
9804 if((x>=combolist[q].x) && (x<combolist[q].x+(combolist[q].xscale*combolist[q].w)))
9805 {
9806 x_on_list = true;
9807 break;
9808 }
9809 }
9810 if(MouseScroll && x_on_list && (key[KEY_LSHIFT] || key[KEY_RSHIFT] || (scrolldelay&3)==0))
9811 {
9812 int32_t test_list=0;
9813
9814 for(test_list=0; test_list<num_combo_cols; ++test_list)
9815 {
9816 if((x>=combolist[test_list].x) && (x<combolist[test_list].x+(combolist[test_list].xscale*combolist[test_list].w)))
9817 {
9818 break;
9819 }
9820 }
9821
9822 if(test_list<num_combo_cols)
9823 {
9824 if(y>=combolist[test_list].y-mouse_scroll_h && y<=combolist[test_list].y && First[test_list])
9825 {
9826 if((CHECK_CTRL_CMD)&&(key[KEY_ALT] || key[KEY_ALTGR]))
9827 {
9828 First[test_list]=0;
9829 }
9830 else if(CHECK_CTRL_CMD)
9831 {
9832 First[test_list]-=zc_min(First[test_list],256);
9833 }
9834 else if(key[KEY_ALT] || key[KEY_ALTGR])
9835 {
9836 First[test_list]-=zc_min(First[test_list],(combolist[test_list].w*combolist[test_list].h));
9837 }
9838 else
9839 {
9840 First[test_list]-=zc_min(First[test_list],combolist[test_list].w);
9841 }
9842 }
9843
9844 if(y>=combolist[test_list].y+(combolist[test_list].h*combolist[test_list].yscale)-1 && y<combolist[test_list].y+(combolist[test_list].h*combolist[test_list].yscale)+mouse_scroll_h-1 && First[test_list]<(MAXCOMBOS-(combolist[test_list].w*combolist[test_list].h)))
9845 {
9846 int32_t offset = combolist[test_list].w*combolist[test_list].h;
9847
9848 if((CHECK_CTRL_CMD)&&(key[KEY_ALT] || key[KEY_ALTGR]))
9849 {
9850 First[test_list]=MAXCOMBOS-offset;
9851 }
9852 else if(CHECK_CTRL_CMD)
9853 {
9854 First[test_list] = zc_min(MAXCOMBOS-offset, First[test_list]+256);
9855 }
9856 else if(key[KEY_ALT] || key[KEY_ALTGR])
9857 {
9858 First[test_list] = zc_min(MAXCOMBOS-offset, First[test_list]+ offset);
9859 }
9860 else
9861 {
9862 First[test_list] = zc_min(MAXCOMBOS - offset, First[test_list] + combolist[test_list].w);
9863 }
9864 }
9865 }
9866 }
9867
9868 // The screen for this combo_pos, layer 0. Used to access ffcs.
9869 mapscr* scr = Map.Scr(combo_pos);
9870 // The screen for this combo_pos at the CurrentLayer. Could be same as scr.
9871 mapscr* draw_mapscr = scr && CurrentLayer ? Map.Scr(combo_pos, CurrentLayer) : scr;
9872 int c = combo_pos.truncate();
9873 set_active_visible_screen(scr);
9874
9875 //-------------
9876 //tooltip stuff
9877 //-------------
9878 if (active_visible_screen && isinRect(x,y,startxint,startyint,startxint+(256*mapscreen_screenunit_scale)-1,startyint+(176*mapscreen_screenunit_scale)-1))
9879 {
9880 static int mapscr_tooltip_id = ttip_register_id();
9881 bool did_ffttip = false;
9882 int num_ffcs = scr->numFFC();
9883 for(int32_t i=num_ffcs-1; i>=0; i--)
9884 if(scr->ffcs[i].data !=0 && (scr->ffcs[i].layer >= CurrentLayer || (scr->ffcs[i].flags&ffc_overlay)))
9885 {
9886 int32_t ffx = scr->ffcs[i].x.getFloor() + active_visible_screen->dx * 256;
9887 int32_t ffy = scr->ffcs[i].y.getFloor() + active_visible_screen->dy * 176;
9888 int32_t ffw = scr->ffTileWidth(i)*16;
9889 int32_t ffh = scr->ffTileHeight(i)*16;
9890 int32_t cx2 = (x-startxint)/mapscreen_single_scale;
9891 int32_t cy2 = (y-startyint)/mapscreen_single_scale;
9892
9893 if(cx2 >= ffx && cx2 < ffx+ffw && cy2 >= ffy && cy2 < ffy+ffh)
9894 {
9895 // FFC tooltip
9896 if(tooltip_current_ffc != i)
9897 {
9898 clear_tooltip();
9899 }
9900
9901 tooltip_current_ffc = i;
9902 char msg[1024] = {0};
9903 auto& ff = scr->ffcs[i];
9904 sprintf(msg,"FFC: %d Combo: %d\nCSet: %d Type: %s\nScript: %s",
9905 i+1, ff.data,ff.data,
9906 combo_class_buf[combobuf[ff.data].type].name,
9907 (ff.script<=0 ? "(None)" : ffcmap[ff.script-1].scriptname.substr(0,400).c_str()));
9908 ttip_install(mapscr_tooltip_id, msg, startxint+(ffx*mapscreen_single_scale), startyint+(ffy*mapscreen_single_scale), ffw*mapscreen_single_scale, ffh*mapscreen_single_scale, x, y);
9909 did_ffttip = true;
9910 break;
9911 }
9912 }
9913 if(!did_ffttip)
9914 {
9915 if(unsigned(c) < 176 && draw_mapscr && !gui_mouse_b())
9916 {
9917 int cid = draw_mapscr->data[c];
9918 newcombo const& cmb = combobuf[cid];
9919 std::ostringstream oss;
9920 int cs = draw_mapscr->cset[c];
9921 int sflag = draw_mapscr->sflag[c];
9922 oss << "Pos: " << c
9923 << "\nCombo: " << cid
9924 << "\nCSet: " << cs;
9925 if(sflag || cmb.flag)
9926 oss << "\nFlags: " << sflag << ", " << (int)cmb.flag;
9927 if(cmb.type)
9928 oss << "\nCombo type: " << combo_class_buf[cmb.type].name;
9929 if(cmb.label[0])
9930 oss << "\nLabel: " << cmb.label;
9931 ttip_install(mapscr_tooltip_id, oss.str().c_str(), startxint+(cx*16*mapscreen_single_scale), startyint+(cy*16*mapscreen_single_scale), 16*mapscreen_single_scale, 16*mapscreen_single_scale, x, y);
9932 }
9933 }
9934 }
9935
9936 {
9937 size_and_pos* squares[4] = {&itemsqr_pos,&stairsqr_pos,&warparrival_pos,&flagsqr_pos};
9938 for(int32_t j=0; j<4; j++)
9939 {
9940 auto& square = *squares[j];
9941 if(square.rect(x,y))
9942 {
9943 char msg[160];
9944 sprintf(msg,
9945 j==0 ? "Item Location" :
9946 j==1 ? "Stairs Secret\nTriggered when a Trigger Push Block is pushed." :
9947 j==2 ? "Arrival Square\nPlayer's location when they begin/resume the game." :
9948 "Combo Flags");
9949 update_tooltip(x,y,square,msg);
9950 }
9951 }
9952
9953 // Warp Returns
9954 for(int32_t j=0; j<4; j++)
9955 {
9956 size_and_pos& wret = warpret_pos[j];
9957 if(wret.rect(x,y))
9958 {
9959 char msg[160];
9960 sprintf(msg,"Warp Return Square %c\nPlayer's destination after warping to this screen.",(char)('A'+j));
9961 update_tooltip(x,y,wret,msg);
9962 }
9963 }
9964
9965 // Enemies
9966 if(enemy_prev_pos.rect(x,y))
9967 {
9968 char msg[160];
9969 sprintf(msg,"Enemies that appear on this screen.");
9970 update_tooltip(x,y,enemy_prev_pos,msg);
9971 }
9972
9973 int32_t cmd = commands_list.rectind(x,y);
9974 if(cmd > -1)
9975 {
9976 update_tooltip(x,y,commands_list.subsquare(cmd),
9977 fmt::format("Fav Command {}: {}\n{}", cmd,
9978 get_hotkey_name(favorite_commands[cmd]),
9979 get_hotkey_helptext(favorite_commands[cmd])).c_str());
9980 }
9981 }
9982
9983 if(draw_mode==dm_alias)
9984 {
9985 for(int32_t j=0; j<num_combo_cols; ++j)
9986 {
9987 auto& sqr = comboaliaslist[j];
9988 auto ind = sqr.rectind(x,y);
9989 if(ind > -1)
9990 {
9991 auto c2=ind+combo_alistpos[j];
9992 char msg[80];
9993 sprintf(msg, "Combo alias %d", c2);
9994 update_tooltip(x,y,sqr.subsquare(ind), msg);
9995 }
9996 }
9997 }
9998 else if(draw_mode==dm_cpool)
9999 {
10000 for(int32_t j=0; j<num_combo_cols; ++j)
10001 {
10002 auto& sqr = comboaliaslist[j];
10003 auto ind = sqr.rectind(x,y);
10004 if(ind > -1)
10005 {
10006 auto c2=ind+combo_pool_listpos[j];
10007 char msg[80];
10008 sprintf(msg, "Combo Pool %d", c2);
10009 update_tooltip(x,y,sqr.subsquare(ind), msg);
10010 }
10011 }
10012 if(cpool_prev_visible && combopool_prevbtn.rect(x,y))
10013 {
10014 if(do_layer_button_reset(combopool_prevbtn.x,combopool_prevbtn.y,
10015 combopool_prevbtn.w,combopool_prevbtn.h,
10016 weighted_cpool ? "Weighted" : "Unweighted",0,true))
10017 {
10018 weighted_cpool = !weighted_cpool;
10019 }
10020 }
10021 }
10022 else if (draw_mode == dm_auto)
10023 {
10024 for (int32_t j = 0; j < num_combo_cols; ++j)
10025 {
10026 auto& sqr = comboaliaslist[j];
10027 auto ind = sqr.rectind(x, y);
10028 if (ind > -1)
10029 {
10030 auto c2 = ind + combo_auto_listpos[j];
10031 char msg[80];
10032 sprintf(msg, "Auto Combo %d", c2);
10033 update_tooltip(x, y, sqr.subsquare(ind), msg);
10034 }
10035 }
10036 }
10037 else
10038 {
10039 if(combo_preview.rect(x,y))
10040 {
10041 auto str = "Combo Colors:\n"+get_combo_colornames(Combo,CSet);
10042 update_tooltip(x,y,combo_preview,str.c_str());
10043 }
10044 else if(comboprev_buf[0] && combo_preview_text1.rect(x,y))
10045 {
10046 update_tooltip(x,y,combo_preview_text1,comboprev_buf);
10047 }
10048 else if(comboprev_buf2[0] && combo_preview_text2.rect(x,y))
10049 {
10050 update_tooltip(x,y,combo_preview_text2,comboprev_buf2);
10051 }
10052 else for(int32_t j=0; j<num_combo_cols; ++j)
10053 {
10054 auto& sqr = combolist[j];
10055 auto ind = sqr.rectind(x,y);
10056 if(ind > -1)
10057 {
10058 int32_t c2=ind+First[j];
10059 std::ostringstream oss;
10060 newcombo const& cmb = combobuf[c2];
10061 oss << "Combo " << c2 << ": " << combo_class_buf[cmb.type].name;
10062 if(cmb.flag != 0)
10063 oss << "\nInherent flag: " << ZI.getMapFlagName(cmb.flag);
10064 if(!cmb.label.empty())
10065 oss << "\nLabel: " << cmb.label;
10066
10067 update_tooltip(x,y,sqr.subsquare(ind), oss.str().c_str());
10068 }
10069 }
10070 }
10071
10072 if (favorites_list.rect(x, y))
10073 {
10074 int32_t f = favorites_list.rectind(x, y);
10075 int32_t row = f / favorites_list.w;
10076 int32_t col = f % favorites_list.w;
10077 f = (row * FAVORITECOMBO_PER_ROW) + col;
10078
10079 auto& sqr = favorites_list.subsquare(col, row);
10080
10081 char buf[180];
10082 if (favorite_combos[f] == -1)
10083 sprintf(buf, "Fav Combo %d\nEmpty", f);
10084 else
10085 {
10086 switch (favorite_combo_modes[f])
10087 {
10088 case dm_alias:
10089 sprintf(buf, "Fav Combo %d\nAlias %d", f, favorite_combos[f]);
10090 break;
10091 case dm_cpool:
10092 sprintf(buf, "Fav Combo %d\nPool %d", f, favorite_combos[f]);
10093 break;
10094 case dm_auto:
10095 sprintf(buf, "Fav Combo %d\nAutocombo %d", f, favorite_combos[f]);
10096 break;
10097 default:
10098 sprintf(buf, "Fav Combo %d\nCombo %d", f, favorite_combos[f]);
10099 }
10100 }
10101 update_tooltip(x, y, sqr, buf);
10102 }
10103
10104 size_and_pos const& real_mini = zoomed_minimap ? real_minimap_zoomed : real_minimap;
10105 auto ind = real_mini.rectind(x,y);
10106 if(ind > -1)
10107 {
10108 char buf[80];
10109 sprintf(buf,"0x%02X (%d)", ind, ind);
10110 ttip_install(minimap_tooltip_id, buf, real_mini.subsquare(ind), real_mini.x+real_mini.tw(), real_mini.y-16);
10111 ttip_set_highlight_thickness(minimap_tooltip_id, zoomed_minimap ? 2 : 1);
10112 // Make sure always above the other tooltip items to the right of the map (even in big map mode).
10113 ttip_set_z_index(minimap_tooltip_id, 100);
10114 ttip_clear_timer();
10115 }
10116 else
10117 {
10118 ttip_uninstall(minimap_tooltip_id);
10119 }
10120
10121 // Mouse clicking stuff
10122 int real_mb = gui_mouse_b();
10123 int mb = real_mb & ~mouse_down; //Only handle clicks that have not been handled already
10124 auto mz = mouse_z;
10125 bool lclick = mb&1;
10126 bool rclick = mb&2;
10127
10128 if (mb && hotkeys_is_active())
10129 {
10130 hotkeys_toggle_display(false);
10131 while (gui_mouse_b())
10132 {
10133 custom_vsync();
10134 }
10135 return;
10136 }
10137
10138 FONT* tfont = font;
10139 if(zoomed_minimap)
10140 {
10141 if((lclick||rclick) && !minimap_zoomed.rect(x,y))
10142 {
10143 // 'Clicked off'
10144 mmap_set_zoom(false);
10145 goto domouse_doneclick;
10146 }
10147 }
10148
10149 if(real_mb==0)
10150 {
10151 mouse_down = 0;
10152 canfill=true;
10153 }
10154 else if(lclick || rclick)
10155 {
10156 //on the minimap
10157 if(real_mini.rect(x,y))
10158 {
10159 if(lclick)
10160 select_scr();
10161 else if(rclick && !(mouse_down&2))
10162 {
10163 mmap_set_zoom(!zoomed_minimap);
10164 }
10165 goto domouse_doneclick;
10166 }
10167
10168 if(zoomed_minimap && minimap_zoomed.rect(x,y))
10169 goto domouse_doneclick; //Eat clicks
10170
10171 //on the map tabs
10172 font = get_custom_font(CFONT_GUI);
10173 for(int32_t btn=0; btn<mappage_count; ++btn)
10174 {
10175 char tbuf[15];
10176 sprintf(tbuf, "%d:%02X", map_page[btn].map+1, map_page[btn].screen);
10177 auto& sqr = map_page_bar[btn];
10178 if(sqr.rect(x,y))
10179 {
10180 if(do_layer_button_reset(sqr.x,sqr.y,sqr.w,sqr.h,tbuf,(btn==current_mappage?D_SELECTED:0)))
10181 {
10182 draw_layer_button(screen, sqr.x,sqr.y,sqr.w,sqr.h,tbuf,D_SELECTED);
10183 map_page[current_mappage].map=Map.getCurrMap();
10184 map_page[current_mappage].screen=Map.getCurrScr();
10185 current_mappage=btn;
10186 Map.setCurrMap(map_page[current_mappage].map);
10187 Map.setCurrScr(map_page[current_mappage].screen);
10188 rebuild_trans_table(); //Woo
10189 }
10190 goto domouse_doneclick;
10191 }
10192 }
10193
10194 if(compactbtn.rect(x,y))
10195 {
10196 if(do_text_button(compactbtn.x, compactbtn.y, compactbtn.w, compactbtn.h, is_compact ? "< Expand" : "> Compact"));
10197 toggle_is_compact();
10198 goto domouse_doneclick;
10199 }
10200
10201 if(!zoom_in_btn_disabled && zoominbtn.rect(x,y))
10202 {
10203 if(do_text_button(zoominbtn.x, zoominbtn.y, zoominbtn.w, zoominbtn.h, "+"))
10204 change_mapscr_zoom(-1);
10205 goto domouse_doneclick;
10206 }
10207
10208 if(!zoom_out_btn_disabled && zoomoutbtn.rect(x,y))
10209 {
10210 if(do_text_button(zoomoutbtn.x, zoomoutbtn.y, zoomoutbtn.w, zoomoutbtn.h, "-"))
10211 change_mapscr_zoom(1);
10212 goto domouse_doneclick;
10213 }
10214
10215 font = get_zc_font(font_lfont_l);
10216 if(combo_merge_btn.rect(x,y))
10217 {
10218 bool merged = is_compact ? compact_merged_combopane : large_merged_combopane;
10219 if(do_text_button(combo_merge_btn.x,combo_merge_btn.y,combo_merge_btn.w,combo_merge_btn.h,merged ? "<|>" : ">|<"))
10220 {
10221 toggle_merged_mode();
10222 }
10223 goto domouse_doneclick;
10224 }
10225
10226 if(favorites_zoombtn.rect(x,y))
10227 {
10228 bool zoomed = is_compact ? compact_zoomed_fav : large_zoomed_fav;
10229 if(do_text_button(favorites_zoombtn.x,favorites_zoombtn.y,favorites_zoombtn.w,favorites_zoombtn.h,zoomed ? "-" : "+"))
10230 {
10231 toggle_favzoom_mode();
10232 }
10233 goto domouse_doneclick;
10234 }
10235 else if(favorites_x.rect(x,y))
10236 {
10237 if(do_text_button(favorites_x.x,favorites_x.y,favorites_x.w,favorites_x.h,"X"))
10238 {
10239 AlertDialog("Clear Favorite Combos",
10240 "Are you sure you want to clear all favorite combos?",
10241 [&](bool ret,bool)
10242 {
10243 if(ret)
10244 {
10245 for(auto q = 0; q < MAXFAVORITECOMBOS; ++q)
10246 {
10247 favorite_combos[q] = -1;
10248 favorite_combo_modes[q] = dm_normal;
10249 }
10250 saved = false;
10251 refresh(rFAVORITES);
10252 }
10253 }).show();
10254 }
10255 goto domouse_doneclick;
10256 }
10257 else if(favorites_infobtn.rect(x,y))
10258 {
10259 if(do_text_button(favorites_infobtn.x,favorites_infobtn.y,favorites_infobtn.w,favorites_infobtn.h,"?"))
10260 {
10261 InfoDialog("Favorite Combos",
10262 "On LClick (empty): Sets clicked favorite to the current combo."
10263 "\nOn LClick: Sets current combo to clicked favorite."
10264 "\nShift+LClick: Sets clicked favorite to current combo."
10265 "\nCtrl+LClick: Clears clicked favorite."
10266 "\nAlt+LClick: Scrolls to clicked favorite."
10267 "\nRClick: Opens context menu."
10268 "\n\nClick the Page buttons (<-/->) to cycle between pages (RClick to jump to a page)"
10269 "\nClick the Zoom button (+/-) to toggle zoom level."
10270 "\nClick the X button to clear all favorite combos.").show();
10271 }
10272 goto domouse_doneclick;
10273 }
10274 else if(favorites_pgleft.rect(x,y))
10275 {
10276 if (do_text_button(favorites_pgleft.x, favorites_pgleft.y, favorites_pgleft.w, favorites_pgleft.h, is_compact ? "<" : "<-"))
10277 {
10278 if (rclick)
10279 {
10280 if(auto val = popup_num_menu(x, y, 1, 9, FavoriteComboPage, [](int p){return fmt::format("Page {}",p);}))
10281 FavoriteComboPage = vbound(*val-1, 0, 8);
10282 }
10283 else
10284 FavoriteComboPage = FavoriteComboPage == 0 ? 8 : --FavoriteComboPage;
10285 reload_zq_gui();
10286 }
10287 goto domouse_doneclick;
10288 }
10289 else if(favorites_pgright.rect(x,y))
10290 {
10291 if (do_text_button(favorites_pgright.x, favorites_pgright.y, favorites_pgright.w, favorites_pgright.h, is_compact ? ">" : "->"))
10292 {
10293 if (rclick)
10294 {
10295 if(auto val = popup_num_menu(x, y, 1, 9, FavoriteComboPage, [](int p){return fmt::format("Page {}",p);}))
10296 FavoriteComboPage = vbound(*val-1, 0, 8);
10297 }
10298 else
10299 FavoriteComboPage = FavoriteComboPage == 8 ? 0 : ++FavoriteComboPage;
10300 reload_zq_gui();
10301 }
10302 goto domouse_doneclick;
10303 }
10304
10305 if(commands_zoombtn.rect(x,y))
10306 {
10307 bool zoomed = is_compact ? compact_zoomed_cmd : large_zoomed_cmd;
10308 if(do_text_button(commands_zoombtn.x,commands_zoombtn.y,commands_zoombtn.w,commands_zoombtn.h,zoomed ? "-" : "+"))
10309 {
10310 toggle_cmdzoom_mode();
10311 }
10312 goto domouse_doneclick;
10313 }
10314 else if(commands_x.rect(x,y))
10315 {
10316 if(do_text_button(commands_x.x,commands_x.y,commands_x.w,commands_x.h,"X"))
10317 {
10318 AlertDialog("Clear Favorite Commands",
10319 "Are you sure you want to clear all favorite commands?",
10320 [&](bool ret,bool)
10321 {
10322 if(ret)
10323 {
10324 char buf[20];
10325 for(auto q = 0; q < MAXFAVORITECOMMANDS; ++q)
10326 {
10327 write_fav_command(q,0);
10328 }
10329 refresh(rFAVORITES);
10330 }
10331 }).show();
10332 }
10333 goto domouse_doneclick;
10334 }
10335 else if(commands_infobtn.rect(x,y))
10336 {
10337 if(do_text_button(commands_infobtn.x,commands_infobtn.y,commands_infobtn.w,commands_infobtn.h,"?"))
10338 {
10339 InfoDialog("Favorite Commands",
10340 "On LClick (empty): Choose a favorite command"
10341 "\nOn LClick: Runs the favorite command"
10342 "\nShift+Click: Choose a favorite command"
10343 "\nRClick: Choose a favorite command"
10344 "\nCtrl+Click: Clears clicked command"
10345 "\nAlt+Click: Shows info on the favorite command"
10346 "\n\nClick the Zoom button (+/-) to toggle zoom level"
10347 "\nClick the X button to clear all favorite commands").show();
10348 }
10349 goto domouse_doneclick;
10350 }
10351 font=tfont;
10352
10353 // On the layer panel
10354 font = get_custom_font(CFONT_GUI);
10355 for(int32_t i=0; i<=6; ++i)
10356 {
10357 int32_t spacing_offs = is_compact ? 2 : 10;
10358 int32_t rx = (i * (layerpanel_buttonwidth+spacing_offs+layerpanel_checkbox_wid)) + layer_panel.x+(is_compact?2:6);
10359 int32_t ry = layer_panel.y;
10360
10361 if ((i == 0 || mapscreen_valid_layers[i - 1]) && isinRect(x,y,rx,ry,rx+layerpanel_buttonwidth-1,ry+layerpanel_buttonheight-1))
10362 {
10363 char tbuf[15];
10364
10365 if (Map.getViewSize() > 1)
10366 {
10367 sprintf(tbuf, "%d", i);
10368 }
10369 else if (i != 0 && mapscreen_valid_layers[i - 1])
10370 {
10371 if (is_compact)
10372 {
10373 sprintf(tbuf, "%s%d %d:%02X",
10374 (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"",
10375 i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
10376 }
10377 else
10378 {
10379 sprintf(tbuf, "%s%d (%d:%02X)",
10380 (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"",
10381 i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
10382 }
10383 }
10384 else
10385 {
10386 sprintf(tbuf, "%d", i);
10387 }
10388
10389 if(do_text_button(rx, ry, layerpanel_buttonwidth, layerpanel_buttonheight, tbuf))
10390 {
10391 CurrentLayer = i;
10392 goto domouse_doneclick;
10393 }
10394 }
10395
10396 auto cbyofs = (layerpanel_buttonheight-layerpanel_checkbox_hei)/2;
10397 if(isinRect(x,y,rx+layerpanel_buttonwidth+1,ry+cbyofs,rx+layerpanel_buttonwidth+1+layerpanel_checkbox_wid-1,ry+2+layerpanel_checkbox_hei-1))
10398 {
10399 do_checkbox(menu1,rx+layerpanel_buttonwidth+1,ry+cbyofs,layerpanel_checkbox_wid,layerpanel_checkbox_hei,LayerMaskInt[i]);
10400 goto domouse_doneclick;
10401 }
10402 }
10403 font=tfont;
10404
10405 //Uses lclick/rclick separately
10406
10407 //on the map screen
10408 if(isinRect(x,y,startxint,startyint,startxint+(256*mapscreen_screenunit_scale)-1,startyint+(176*mapscreen_screenunit_scale)-1))
10409 {
10410 if (lclick)
10411 {
10412 Map.setCurrScr(Map.getScreenForPosition(combo_pos));
10413 }
10414
10415 if (draw_mode == dm_auto)
10416 {
10417 if (CHECK_CTRL_CMD)
10418 {
10419 if (canfill)
10420 {
10421 switch (fill_type)
10422 {
10423 case 0:
10424 flood();
10425 break;
10426
10427 case 1:
10428 fill_4();
10429 break;
10430
10431 case 2:
10432 fill_8();
10433 break;
10434
10435 case 3:
10436 fill2_4();
10437 break;
10438
10439 case 4:
10440 fill2_8();
10441 break;
10442 }
10443
10444 canfill = false;
10445 }
10446 }
10447 else
10448 draw(key[KEY_LSHIFT] || key[KEY_RSHIFT]);
10449 }
10450 else if (scr && lclick)
10451 {
10452 int32_t cx2 = (x-startxint)/mapscreen_single_scale;
10453 int32_t cy2 = (y-startyint)/mapscreen_single_scale;
10454
10455 // Move items
10456 if (scr->hasitem && active_visible_screen)
10457 {
10458 int32_t ix = scr->itemx + active_visible_screen->dx * 256;
10459 int32_t iy = scr->itemy + active_visible_screen->dy * 176;
10460
10461 if(cx2 >= ix && cx2 < ix+16 && cy2 >= iy && cy2 < iy+16)
10462 doxypos(scr->itemx, scr->itemy, 11, SNAP_HALF, SNAP_NONE, true, 0, 0, 16, 16);
10463 }
10464
10465 // Move FFCs
10466 int num_ffcs = scr->numFFC();
10467 for(int32_t i=num_ffcs-1; i>=0; i--)
10468 if(scr->ffcs[i].data !=0 && (scr->ffcs[i].layer >= CurrentLayer || (scr->ffcs[i].flags&ffc_overlay)))
10469 {
10470 int32_t ffx = scr->ffcs[i].x.getFloor() + active_visible_screen->dx * 256;
10471 int32_t ffy = scr->ffcs[i].y.getFloor() + active_visible_screen->dy * 176;
10472
10473 if(cx2 >= ffx && cx2 < ffx+(scr->ffTileWidth(i)*16) && cy2 >= ffy && cy2 < ffy+(scr->ffTileHeight(i)*16))
10474 {
10475 moveffc(i, cx2, cy2);
10476 break;
10477 }
10478 }
10479
10480 if(key[KEY_ALT]||key[KEY_ALTGR])
10481 {
10482 if (!draw_mapscr) return;
10483
10484 Combo=draw_mapscr->data[c];
10485 if(AutoBrush)
10486 BrushWidth = BrushHeight = 1;
10487 if(key[KEY_LSHIFT]||key[KEY_RSHIFT])
10488 CSet=draw_mapscr->cset[c];
10489 if(CHECK_CTRL_CMD)
10490 First[current_combolist]=scrollto_cmb(draw_mapscr->data[c]);
10491 }
10492 else if(CHECK_CTRL_CMD)
10493 {
10494 if(canfill)
10495 {
10496 switch(fill_type)
10497 {
10498 case 0:
10499 flood();
10500 break;
10501
10502 case 1:
10503 fill_4();
10504 break;
10505
10506 case 2:
10507 fill_8();
10508 break;
10509
10510 case 3:
10511 fill2_4();
10512 break;
10513
10514 case 4:
10515 fill2_8();
10516 break;
10517 }
10518
10519 canfill=false;
10520 }
10521 }
10522 else draw(key[KEY_LSHIFT] || key[KEY_RSHIFT]);
10523 }
10524 else if (scr && rclick)
10525 {
10526 ComboBrushPause=1;
10527 refresh(rMAP);
10528 restore_mouse();
10529 ComboBrushPause=0;
10530
10531 bool clickedffc = false;
10532
10533 // FFC right-click menu
10534 // This loop also serves to find the free ffc with the smallest slot number.
10535 int num_ffcs = scr->numFFC();
10536 uint32_t earliestfreeffc = num_ffcs;
10537 for(int32_t i=num_ffcs-1; i>=0; i--)
10538 {
10539 auto data = scr->ffcs[i].data;
10540 if(data==0)
10541 {
10542 if(i < earliestfreeffc)
10543 earliestfreeffc = i;
10544 continue;
10545 }
10546
10547 if(clickedffc || !(scr->valid&mVALID))
10548 continue;
10549
10550 if(data!=0 && (scr->ffcs[i].layer >= CurrentLayer || (scr->ffcs[i].flags&ffc_overlay)))
10551 {
10552 int32_t ffx = scr->ffcs[i].x.getFloor() + active_visible_screen->dx * 256;
10553 int32_t ffy = scr->ffcs[i].y.getFloor() + active_visible_screen->dy * 176;
10554 int32_t cx2 = (x-startxint)/mapscreen_single_scale;
10555 int32_t cy2 = (y-startyint)/mapscreen_single_scale;
10556
10557 if(cx2 >= ffx && cx2 < ffx+(scr->ffTileWidth(i)*16) && cy2 >= ffy && cy2 < ffy+(scr->ffTileHeight(i)*16))
10558 {
10559 NewMenu rcmenu
10560 {
10561 { "Copy FFC", [&](){Map.CopyFFC(active_visible_screen->screen, i);} },
10562 { "Paste FFC data", [&]()
10563 {
10564 bool didconfirm = false;
10565 AlertDialog("Confirm Paste",
10566 "Really replace the FFC with the data of the copied FFC?",
10567 [&](bool ret,bool)
10568 {
10569 if(ret)
10570 didconfirm = true;
10571 }).show();
10572 if(didconfirm)
10573 {
10574 auto set_ffc_data = Map.getCopyFFCData();
10575 set_ffc_data.x = scr->ffcs[i].x;
10576 set_ffc_data.y = scr->ffcs[i].y;
10577 Map.DoSetFFCCommand(Map.getCurrMap(), active_visible_screen->screen, i, set_ffc_data);
10578 }
10579 }, nullopt, Map.getCopyFFC() < 0 },
10580 { "Edit FFC", [&](){call_ffc_dialog(i, active_visible_screen->scr, active_visible_screen->screen);} },
10581 { "Clear FFC", [&]()
10582 {
10583 bool didconfirm = false;
10584 AlertDialog("Confirm Clear",
10585 "Really clear this Freeform Combo?",
10586 [&](bool ret,bool)
10587 {
10588 if(ret)
10589 didconfirm = true;
10590 }).show();
10591 if(didconfirm)
10592 {
10593 Map.DoSetFFCCommand(Map.getCurrMap(), active_visible_screen->screen, i, {
10594 .x = 0,
10595 .y = 0,
10596 .vx = 0,
10597 .vy = 0,
10598 .ax = 0,
10599 .ay = 0,
10600 .data = 0,
10601 .cset = 0,
10602 .delay = 0,
10603 .link = 0,
10604 .script = 0,
10605 .tw = 1,
10606 .th = 1,
10607 .ew = 16,
10608 .eh = 16,
10609 .flags = ffc_none,
10610 .initd = 0,
10611 });
10612 saved = false;
10613 }
10614 } },
10615 { "Snap to Grid", [&]()
10616 {
10617 int oldffx = scr->ffcs[i].x.getInt();
10618 int oldffy = scr->ffcs[i].y.getInt();
10619 int pos = COMBOPOS(oldffx,oldffy);
10620 int newffy = COMBOY(pos);
10621 int newffx = COMBOX(pos);
10622
10623 auto set_ffc_data = set_ffc_command::create_data(scr->ffcs[i]);
10624 set_ffc_data.x = newffx;
10625 set_ffc_data.y = newffy;
10626 Map.DoSetFFCCommand(Map.getCurrMap(), active_visible_screen->screen, i, set_ffc_data);
10627
10628 saved = false;
10629 } },
10630 };
10631 rcmenu.pop(x, y);
10632 clickedffc = true;
10633 break;
10634 }
10635 }
10636 }
10637
10638 // Combo right-click menu
10639 if(!clickedffc)
10640 {
10641 int warpindex = Map.warpindex(scr->data[c]);
10642 string txt_twarp_follow, txt_twarp_edit, txt_ffc_edit, txt_ffc_paste;
10643 bool show_ffcs = earliestfreeffc < MAXFFCS;
10644 bool dis_paste_ffc = Map.getCopyFFC() < 0;
10645 bool show_warps = warpindex > -1;
10646 bool show_warpback = Map.has_warpback();
10647 // FFC-specific options
10648 if(earliestfreeffc < MAXFFCS)
10649 {
10650 txt_ffc_edit = fmt::format("Edit New FFC {}",earliestfreeffc+1);
10651 if(Map.getCopyFFC()>-1)
10652 txt_ffc_paste = fmt::format("Paste FFC as FFC {}",earliestfreeffc+1);
10653 else
10654 txt_ffc_paste = "Paste FFC";
10655 }
10656
10657 if(warpindex > -1)
10658 {
10659 char letter = warpindex==4 ? 'R' : 'A'+warpindex;
10660 txt_twarp_follow = fmt::format("Follow Tile Warp {}",letter);
10661 txt_twarp_edit = fmt::format("Edit Tile Warp {}",letter);
10662 }
10663
10664 NewMenu draw_rc_menu
10665 {
10666 { "Select Combo", [&]()
10667 {
10668 Combo = draw_mapscr->data[c];
10669 if(AutoBrush)
10670 BrushWidth = BrushHeight = 1;
10671 }, nullopt, !draw_mapscr },
10672 { "Scroll to Combo", [&]()
10673 {
10674 First[current_combolist] = scrollto_cmb(draw_mapscr->data[c]);
10675 }, nullopt, !draw_mapscr },
10676 { "Edit Combo", [&]()
10677 {
10678 edit_combo(draw_mapscr->data[c],true,draw_mapscr->cset[c]);
10679 }, nullopt, !draw_mapscr },
10680 {},
10681 { "Replace All", [&](){replace(combo_pos);} },
10682 { "Draw Block", &draw_block_menu },
10683 { "Brush Settings ", &brush_menu },
10684 { "Set Fill Type ", &fill_menu },
10685 };
10686 if(show_warps || show_warpback)
10687 {
10688 draw_rc_menu.add_sep();
10689 if(show_warpback)
10690 draw_rc_menu.add({ "Warp Back", [&](){Map.warpback();} });
10691 if(show_warps)
10692 {
10693 draw_rc_menu.add({ txt_twarp_follow, [&](){follow_twarp(warpindex);} });
10694 draw_rc_menu.add({ txt_twarp_edit, [&](){edit_twarp(warpindex);} });
10695 }
10696 }
10697 if(show_ffcs)
10698 {
10699 draw_rc_menu.add_sep();
10700 draw_rc_menu.add({ txt_ffc_edit, [&]()
10701 {
10702 ffdata tempdat;
10703 // x, y are ints on ffdata (but ffc x, y are zfix), so *10000
10704 tempdat.x = ((int((x-startxint)/mapscreen_single_scale)&(~0x0007)) % 256) * 10000;
10705 tempdat.y = ((int((y-startyint)/mapscreen_single_scale)&(~0x0007)) % 176) * 10000;
10706 tempdat.data = Combo;
10707 tempdat.cset = CSet;
10708 call_ffc_dialog(earliestfreeffc, tempdat, active_visible_screen->scr, active_visible_screen->screen);
10709 } });
10710 draw_rc_menu.add({ txt_ffc_paste, [&]()
10711 {
10712 auto set_ffc_data = Map.getCopyFFCData();
10713 set_ffc_data.x = ((int((x-startxint)/mapscreen_single_scale)&(~0x0007)) % 256);
10714 set_ffc_data.y = ((int((y-startyint)/mapscreen_single_scale)&(~0x0007)) % 176);
10715 Map.DoSetFFCCommand(Map.getCurrMap(), active_visible_screen->screen, earliestfreeffc, set_ffc_data);
10716 }, nullopt, dis_paste_ffc });
10717 }
10718 draw_rc_menu.add_sep();
10719 draw_rc_menu.add({ "Screen", &rc_menu_screen });
10720 draw_rc_menu.pop(x,y);
10721 }
10722 }
10723 goto domouse_doneclick;
10724 }
10725
10726 //on the drawing mode button
10727 font = get_custom_font(CFONT_GUI);
10728 if(drawmode_btn.rect(x,y))
10729 {
10730 if(lclick)
10731 {
10732 if(do_text_button(drawmode_btn.x,drawmode_btn.y,drawmode_btn.w,drawmode_btn.h,dm_names[draw_mode]))
10733 onDrawingMode();
10734 }
10735 else if(rclick)
10736 drawing_mode_menu.pop(x,y);
10737 goto domouse_doneclick;
10738 }
10739 font=tfont;
10740
10741 //Squares
10742 //
10743 set_active_visible_screen(Map.CurrScr());
10744 {
10745 if(squarepanel_swap_btn.rect(x,y))
10746 {
10747 toggle_compact_sqr_mode();
10748 goto domouse_doneclick;
10749 }
10750 if(squarepanel_up_btn.rect(x,y))
10751 {
10752 cycle_compact_sqr(false);
10753 goto domouse_doneclick;
10754 }
10755 if(squarepanel_down_btn.rect(x,y))
10756 {
10757 cycle_compact_sqr(true);
10758 goto domouse_doneclick;
10759 }
10760
10761 bool do_dummyxy = false;
10762 bool dummymode = key[KEY_LSHIFT] || key[KEY_RSHIFT];
10763
10764 if(itemsqr_pos.rect(x,y))
10765 {
10766 if(dummymode) do_dummyxy = true;
10767 else
10768 {
10769 onItem();
10770
10771 if(!rclick && Map.CurrScr()->hasitem)
10772 doxypos(Map.CurrScr()->itemx,Map.CurrScr()->itemy,11,SNAP_HALF,SNAP_NONE);
10773 goto domouse_doneclick;
10774 }
10775 }
10776
10777 if(stairsqr_pos.rect(x,y))
10778 {
10779 if(dummymode) do_dummyxy = true;
10780 else
10781 {
10782 doxypos(Map.CurrScr()->stairx,Map.CurrScr()->stairy,14,SNAP_WHOLE);
10783 goto domouse_doneclick;
10784 }
10785 }
10786
10787 if(warparrival_pos.rect(x,y))
10788 {
10789 if(dummymode) do_dummyxy = true;
10790 else
10791 {
10792 if(get_qr(qr_NOARRIVALPOINT))
10793 {
10794 info_dsa("Arrival Square",
10795 "The arrival square cannot be used unless the QR 'Use Warp Return "
10796 "Points Only' under 'Quest->Options->Combos' is disabled."
10797 "\nGenerally, this square only exists for compatibility purposes, and is not used"
10798 " in creating new quests.",
10799 "dsa_warparrival");
10800 }
10801 else doxypos(Map.CurrScr()->warparrivalx,Map.CurrScr()->warparrivaly,10,SNAP_HALF,SNAP_NONE);
10802 goto domouse_doneclick;
10803 }
10804 }
10805
10806 if(flagsqr_pos.rect(x,y))
10807 {
10808 if(dummymode) do_dummyxy = true;
10809 else
10810 {
10811 onFlags();
10812 goto domouse_doneclick;
10813 }
10814 }
10815
10816 for(auto q = 0; q < 4; ++q)
10817 {
10818 if(warpret_pos[q].rect(x,y))
10819 {
10820 if(dummymode) do_dummyxy = true;
10821 else
10822 {
10823 doxypos(Map.CurrScr()->warpreturnx[q],Map.CurrScr()->warpreturny[q],9,SNAP_HALF,SNAP_NONE);
10824 goto domouse_doneclick;
10825 }
10826 }
10827 }
10828
10829 if(enemy_prev_pos.rect(x,y))
10830 {
10831 if(dummymode) do_dummyxy = true;
10832 else
10833 {
10834 onEnemies();
10835 goto domouse_doneclick;
10836 }
10837 }
10838
10839 if(do_dummyxy)
10840 {
10841 byte x = 0, y = 0;
10842 showxypos_dummy = true;
10843 doxypos(x,y,13,SNAP_HALF,SNAP_NONE);
10844 goto domouse_doneclick;
10845 }
10846 }
10847
10848 if(draw_mode==dm_alias)
10849 {
10850 for(int32_t j=0; j<num_combo_cols; ++j)
10851 {
10852 if(combolistscrollers[j].rectind(x,y)==0 && !mouse_down)
10853 {
10854 scrollup(j);
10855 goto domouse_doneclick;
10856 }
10857 else if(combolistscrollers[j].rectind(x,y)==1 && !mouse_down)
10858 {
10859 scrolldown(j);
10860 goto domouse_doneclick;
10861 }
10862 else if(comboaliaslist[j].rect(x,y))
10863 {
10864 select_comboa(j);
10865
10866 if(rclick && comboaliaslist[j].rect(gui_mouse_x(),gui_mouse_y()))
10867 popup_cpane_rc(x, y);
10868 goto domouse_doneclick;
10869 }
10870 }
10871 }
10872 else if(draw_mode==dm_cpool)
10873 {
10874 for(int32_t j=0; j<num_combo_cols; ++j)
10875 {
10876 if(combolistscrollers[j].rectind(x,y)==0 && !mouse_down)
10877 {
10878 scrollup(j);
10879 goto domouse_doneclick;
10880 }
10881 else if(combolistscrollers[j].rectind(x,y)==1 && !mouse_down)
10882 {
10883 scrolldown(j);
10884 goto domouse_doneclick;
10885 }
10886 else if(comboaliaslist[j].rect(x,y))
10887 {
10888 select_combop(j);
10889
10890 if(rclick && comboaliaslist[j].rect(gui_mouse_x(),gui_mouse_y()))
10891 popup_cpane_rc(x, y);
10892 goto domouse_doneclick;
10893 }
10894 }
10895 }
10896 else if (draw_mode == dm_auto)
10897 {
10898 for (int32_t j = 0; j < num_combo_cols; ++j)
10899 {
10900 if (combolistscrollers[j].rectind(x, y) == 0 && !mouse_down)
10901 {
10902 scrollup(j);
10903 goto domouse_doneclick;
10904 }
10905 else if (combolistscrollers[j].rectind(x, y) == 1 && !mouse_down)
10906 {
10907 scrolldown(j);
10908 goto domouse_doneclick;
10909 }
10910 else if (comboaliaslist[j].rect(x, y))
10911 {
10912 select_autocombo(j);
10913
10914 if(rclick && comboaliaslist[j].rect(gui_mouse_x(),gui_mouse_y()))
10915 popup_cpane_rc(x, y);
10916 goto domouse_doneclick;
10917 }
10918 }
10919 }
10920 else
10921 {
10922 for(int32_t j=0; j<num_combo_cols; ++j)
10923 {
10924 if(combolistscrollers[j].rectind(x,y)==0 && !mouse_down)
10925 {
10926 scrollup(j);
10927 goto domouse_doneclick;
10928 }
10929 else if(combolistscrollers[j].rectind(x,y)==1 && !mouse_down)
10930 {
10931 scrolldown(j);
10932 goto domouse_doneclick;
10933 }
10934 else if(combolist[j].rect(x,y))
10935 {
10936 select_combo(j);
10937
10938 if(rclick && combolist[j].rect(gui_mouse_x(),gui_mouse_y()))
10939 popup_cpane_rc(x, y);
10940 goto domouse_doneclick;
10941 }
10942 }
10943 }
10944
10945 //on the favorites list
10946 if(favorites_list.rect(x,y))
10947 {
10948 if(lclick)
10949 {
10950 int32_t f=favorites_list.rectind(x,y);
10951 int32_t row=f/favorites_list.w;
10952 int32_t col=f%favorites_list.w;
10953 f = (row*FAVORITECOMBO_PER_ROW)+col;
10954 int32_t fp = f + FAVORITECOMBO_PER_PAGE * FavoriteComboPage;
10955
10956 bool dmcond = favorite_combos[fp] < 0;
10957 if((key[KEY_LSHIFT] || key[KEY_RSHIFT] || dmcond) && !(CHECK_CTRL_CMD))
10958 {
10959 int32_t tempcb=ComboBrush;
10960 ComboBrush=0;
10961
10962 while(gui_mouse_b())
10963 {
10964 x=gui_mouse_x();
10965 y=gui_mouse_y();
10966
10967 switch(draw_mode)
10968 {
10969 case dm_alias:
10970 if (favorite_combos[fp] != combo_apos || favorite_combo_modes[fp] != dm_alias)
10971 {
10972 favorite_combo_modes[fp] = dm_alias;
10973 favorite_combos[fp] = combo_apos;
10974 saved = false;
10975 }
10976 break;
10977 case dm_cpool:
10978 if (favorite_combos[fp] != combo_pool_pos || favorite_combo_modes[fp] != dm_cpool)
10979 {
10980 favorite_combo_modes[fp] = dm_cpool;
10981 favorite_combos[fp] = combo_pool_pos;
10982 saved = false;
10983 }
10984 break;
10985 case dm_auto:
10986 if (favorite_combos[fp] != combo_auto_pos || favorite_combo_modes[fp] != dm_auto)
10987 {
10988 favorite_combo_modes[fp] = dm_auto;
10989 favorite_combos[fp] = combo_auto_pos;
10990 saved = false;
10991 }
10992 break;
10993 default:
10994 if (favorite_combos[fp] != Combo || favorite_combo_modes[fp] != dm_normal)
10995 {
10996 if (BrushWidth > 1 || BrushHeight > 1)
10997 {
10998 add_favorite_combo_block(f, Combo, key[KEY_LSHIFT] || key[KEY_RSHIFT]);
10999 break;
11000 }
11001 favorite_combo_modes[fp] = dm_normal;
11002 favorite_combos[fp] = Combo;
11003 saved = false;
11004 }
11005 }
11006
11007 custom_vsync();
11008 refresh(rALL | rFAVORITES);
11009 }
11010
11011 ComboBrush=tempcb;
11012 }
11013 else if(CHECK_CTRL_CMD)
11014 {
11015 int32_t tempcb=ComboBrush;
11016 ComboBrush=0;
11017
11018 while(gui_mouse_b())
11019 {
11020 x=gui_mouse_x();
11021 y=gui_mouse_y();
11022
11023 if(favorite_combos[fp]!=-1)
11024 {
11025 favorite_combo_modes[fp] = dm_normal;
11026 favorite_combos[fp]=-1;
11027 saved=false;
11028 }
11029
11030 custom_vsync();
11031 refresh(rALL | rFAVORITES);
11032 }
11033
11034 ComboBrush=tempcb;
11035 }
11036 else if(key[KEY_ALT] || key[KEY_ALTGR])
11037 {
11038 if(select_favorite())
11039 {
11040 switch(favorite_combo_modes[fp])
11041 {
11042 case dm_alias:
11043 combo_alistpos[current_comboalist]=scrollto_alias(combo_apos);
11044 break;
11045 case dm_cpool:
11046 combo_pool_listpos[current_cpoollist] = scrollto_cpool(combo_pool_pos);
11047 break;
11048 case dm_auto:
11049 combo_auto_listpos[current_cautolist] = scrollto_cauto(combo_auto_pos);
11050 break;
11051 default:
11052 First[current_combolist]=scrollto_cmb(Combo);
11053 }
11054 }
11055 }
11056 else
11057 {
11058 select_favorite();
11059 }
11060 }
11061 else if(rclick)
11062 {
11063 bool valid=select_favorite();
11064
11065 if(valid)
11066 {
11067 int f = favorites_list.rectind(x,y);
11068 int row = f/favorites_list.w;
11069 int col = f%favorites_list.w;
11070 f = (row*FAVORITECOMBO_PER_ROW) + col + (FAVORITECOMBO_PER_PAGE * FavoriteComboPage);
11071 popup_favorites_rc(f, x, y);
11072 }
11073 }
11074 goto domouse_doneclick;
11075 }
11076
11077 //on the commands buttons
11078 int32_t cmd = commands_list.rectind(x,y);
11079 if(cmd > -1)
11080 {
11081 uint hkey = favorite_commands[cmd];
11082 bool shift=(key[KEY_LSHIFT] || key[KEY_RSHIFT]);
11083 bool ctrl=(CHECK_CTRL_CMD);
11084 bool alt=(key[KEY_ALT] || key[KEY_ALTGR]);
11085 bool dis = disabled_hotkey(hkey);
11086 auto& btn = commands_list.subsquare(cmd);
11087 if(!dis||rclick||shift||ctrl||alt)
11088 {
11089 FONT *tfont=font;
11090 font=get_custom_font(CFONT_FAVCMD);
11091 if(do_layer_button_reset(btn.x,btn.y,btn.w,btn.h,
11092 get_hotkey_name(hkey),
11093 selected_hotkey(hkey)?D_SELECTED:0,
11094 true))
11095 {
11096 font=tfont;
11097 if(alt)
11098 {
11099 show_hotkey_info(hkey);
11100 }
11101 else if(ctrl)
11102 {
11103 write_fav_command(cmd,0);
11104 }
11105 else if(rclick || shift || hkey==ZQKEY_NULL_KEY)
11106 {
11107 if(auto newkey = select_fav_command())
11108 write_fav_command(cmd,*newkey);
11109 }
11110 else
11111 {
11112 run_hotkey(hkey);
11113 }
11114 }
11115
11116 font=tfont;
11117 }
11118 goto domouse_doneclick;
11119 }
11120 }
11121
11122 domouse_doneclick:
11123 mouse_down |= mb&3;
11124
11125 if(mouse_z!=0)
11126 {
11127 int32_t z=0;
11128
11129 for(int32_t j=0; j<num_combo_cols; ++j)
11130 {
11131 z=abs(mouse_z);
11132
11133 if(key[KEY_ALT]||key[KEY_ALTGR])
11134 {
11135 z*=combolist[j].h;
11136 }
11137
11138
11139 if(draw_mode == dm_alias)
11140 {
11141 if(comboaliaslist[j].rect(x,y))
11142 {
11143 if(mouse_z<0) //scroll down
11144 {
11145 combo_alistpos[current_comboalist] = zc_min(MAXCOMBOALIASES - comboaliaslist[j].w*comboaliaslist[j].h,
11146 combo_alistpos[current_comboalist]+comboaliaslist[j].w*z);
11147 }
11148 else //scroll up
11149 {
11150 if(combo_alistpos[current_comboalist]>0)
11151 {
11152 combo_alistpos[current_comboalist]-=zc_min(combo_alistpos[current_comboalist],comboaliaslist[j].w*z);
11153 }
11154 }
11155 goto domouse_donez;
11156 }
11157 }
11158 else if(draw_mode == dm_cpool)
11159 {
11160 if(comboaliaslist[j].rect(x,y))
11161 {
11162 if(mouse_z<0) //scroll down
11163 {
11164 combo_pool_listpos[current_cpoollist] = zc_min(MAXCOMBOPOOLS - comboaliaslist[j].w*comboaliaslist[j].h,
11165 combo_pool_listpos[current_cpoollist]+comboaliaslist[j].w*z);
11166 }
11167 else //scroll up
11168 {
11169 if(combo_pool_listpos[current_cpoollist]>0)
11170 {
11171 combo_pool_listpos[current_cpoollist]-=zc_min(combo_pool_listpos[current_cpoollist],comboaliaslist[j].w*z);
11172 }
11173 }
11174 goto domouse_donez;
11175 }
11176 }
11177 else if (draw_mode == dm_auto)
11178 {
11179 if (comboaliaslist[j].rect(x, y))
11180 {
11181 if (mouse_z < 0) //scroll down
11182 {
11183 combo_auto_listpos[current_cautolist] = zc_min(MAXAUTOCOMBOS - comboaliaslist[j].w * comboaliaslist[j].h,
11184 combo_auto_listpos[current_cautolist] + comboaliaslist[j].w * z);
11185 }
11186 else //scroll up
11187 {
11188 if (combo_auto_listpos[current_cautolist] > 0)
11189 {
11190 combo_auto_listpos[current_cautolist] -= zc_min(combo_auto_listpos[current_cautolist], comboaliaslist[j].w * z);
11191 }
11192 }
11193 goto domouse_donez;
11194 }
11195 }
11196 else
11197 {
11198 if(combolist[j].rect(x,y))
11199 {
11200 if(mouse_z<0) //scroll down
11201 {
11202 First[current_combolist] = zc_min(MAXCOMBOS-combolist[j].w*combolist[j].h,
11203 First[current_combolist] + combolist[j].w*z);
11204 }
11205 else //scroll up
11206 {
11207 if(First[current_combolist]>0)
11208 {
11209 First[current_combolist]-=zc_min(First[current_combolist],combolist[j].w*z);
11210 }
11211 }
11212 goto domouse_donez;
11213 }
11214 }
11215 }
11216
11217 z=abs(mouse_z);
11218
11219 if(real_mini.rect(x,y))
11220 {
11221 for(int32_t i=0; i<z; ++i)
11222 {
11223 if(mouse_z>0) onIncMap();
11224 else onDecMap();
11225 }
11226 goto domouse_donez;
11227 }
11228
11229 if(is_compact && compact_square_panels
11230 && squares_panel.rect(x,y))
11231 {
11232 cycle_compact_sqr(mouse_z < 0);
11233 goto domouse_donez;
11234 }
11235 domouse_donez:
11236 position_mouse_z(0);
11237 }
11238 font = tfont;
11239 active_visible_screen = nullptr;
11240 }
11241
11242 int32_t d_viewpal_proc(int32_t msg, DIALOG *d, int32_t c)
11243 {
11244 int32_t ret = d_bitmap_proc(msg, d, c);
11245 char* buf = (char*)d->dp2; //buffer to store the color code in
11246 DIALOG* d2 = (DIALOG*)d->dp3; //DIALOG* to update the text proc
11247 if(!buf)
11248 return ret;
11249 switch(msg)
11250 {
11251 case MSG_IDLE:
11252 case MSG_GOTMOUSE:
11253 case MSG_LOSTMOUSE:
11254 break;
11255 default:
11256 return ret;
11257 }
11258 char t[16];
11259 memcpy(t, buf, 16);
11260 int32_t x = gui_mouse_x() - d->x;
11261 int32_t y = gui_mouse_y() - d->y;
11262 if(msg != MSG_LOSTMOUSE && isinRect(x, y, 0, 0, d->w-1, d->h-1))
11263 {
11264 float palscale = 1.5;
11265 for(int32_t i = 0; i<256; ++i)
11266 if(isinRect(x,y,(int32_t)(((i&31)<<3)*palscale),(int32_t)(((i&0xE0)>>2)*palscale), (int32_t)((((i&31)<<3)+7)*palscale),(int32_t)((((i&0xE0)>>2)+7)*palscale)))
11267 {
11268 sprintf(buf, "0x%02X (%03d) ", i, i); //Extra spaces to increase drawn width, so it draws the blank area
11269 break;
11270 }
11271 }
11272 else memset(buf, ' ', 15);
11273 if(strcmp(buf, t) && d2 && d2->proc == jwin_text_proc && d2->dp == d->dp2)
11274 object_message(d2, MSG_DRAW, 0);
11275 return ret;
11276 }
11277
11278 static DIALOG showpal_dlg[] =
11279 {
11280 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11281 { jwin_win_proc, 24, 68, 272, 119, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "View Palette", NULL, NULL },
11282 { jwin_frame_proc, 30, 76+16, 260, 68, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
11283 { d_viewpal_proc, 32, 76+18, 256, 64, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11284 { jwin_text_proc, 32+8,76+18+66, 20, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
11285 { jwin_button_proc, 130, 144+18, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11286 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11287 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11288 };
11289
11290 int32_t onShowPal()
11291 {
11292 float palscale = 1.5;
11293
11294 BITMAP *palbmp = create_bitmap_ex(8,(int32_t)(256*palscale),(int32_t)(64*palscale));
11295
11296 if(!palbmp)
11297 return D_O_K;
11298 clear_to_color(palbmp,jwin_pal[jcBOX]); //If not cleared, random static appears between swatches! -E
11299 showpal_dlg[0].dp2=get_zc_font(font_lfont);
11300
11301 for(int32_t i=0; i<256; i++)
11302 rectfill(palbmp,(int32_t)(((i&31)<<3)*palscale),(int32_t)(((i&0xE0)>>2)*palscale), (int32_t)((((i&31)<<3)+7)*palscale),(int32_t)((((i&0xE0)>>2)+7)*palscale),i);
11303 showpal_dlg[2].dp=(void *)palbmp;
11304 char buf[16] = {0};
11305 showpal_dlg[2].dp2=(void *)buf;
11306 showpal_dlg[2].dp3=(void *)&(showpal_dlg[3]);
11307 showpal_dlg[3].dp=(void *)buf;
11308 showpal_dlg[3].dp2=(void *)get_zc_font(font_deffont);
11309
11310 large_dialog(showpal_dlg);
11311 do_zqdialog(showpal_dlg,2);
11312 destroy_bitmap(palbmp);
11313 return D_O_K;
11314 }
11315
11316 static DIALOG csetfix_dlg[] =
11317 {
11318 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11319 { jwin_win_proc, 72, 80, 176+1, 96+1, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "CSet Fix", NULL, NULL },
11320 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11321 { jwin_radio_proc, 104+22, 108, 80+1, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "Full Screen", NULL, NULL },
11322 { jwin_radio_proc, 104+22, 118+2, 80+1, 8+1, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "Dungeon Floor", NULL, NULL },
11323 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
11324 { jwin_check_proc, 104+22, 128+4, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, (void *) "All Layers", NULL, NULL },
11325 { jwin_button_proc, 90, 152, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11326 { jwin_button_proc, 170, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11327 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11328 };
11329
11330 int32_t onCSetFix()
11331 {
11332 restore_mouse();
11333 csetfix_dlg[0].dp2=get_zc_font(font_lfont);
11334 int32_t s=2,x2=14,y2=9;
11335
11336 large_dialog(csetfix_dlg);
11337
11338 if(do_zqdialog(csetfix_dlg,-1)==6)
11339 {
11340 if(csetfix_dlg[2].flags&D_SELECTED)
11341 {
11342 s=0;
11343 x2=16;
11344 y2=11;
11345 }
11346
11347 if(csetfix_dlg[5].flags&D_SELECTED)
11348 {
11349 /*
11350 int32_t drawmap, drawscr;
11351 if (CurrentLayer==0)
11352 {
11353 drawmap=Map.getCurrMap();
11354 drawscr=Map.getCurrScr();
11355 }
11356 else
11357 {
11358 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
11359 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
11360 }
11361 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
11362 if(!draw_mapscr) return;
11363 saved=false;
11364 Map.Ugo();
11365
11366 if(!(draw_mapscr->valid&mVALID))
11367 {
11368 Map.CurrScr()->valid|=mVALID;
11369 draw_mapscr->valid|=mVALID;
11370 Map.setcolor(Color);
11371 }
11372 for(int32_t i=0; i<176; i++)
11373 {
11374 draw_mapscr->data[i]=Combo;
11375 draw_mapscr->cset[i]=CSet;
11376 }
11377 refresh(rMAP+rSCRMAP);
11378 */
11379 }
11380
11381 Map.StartListCommand();
11382 for(int32_t y=s; y<y2; y++)
11383 {
11384 for(int32_t x=s; x<x2; x++)
11385 {
11386 Map.DoSetComboCommand(Map.getCurrMap(), Map.getCurrScr(), (y<<4)+x, -1, CSet);
11387 }
11388 }
11389 Map.FinishListCommand();
11390
11391 refresh(rMAP);
11392 saved = false;
11393 }
11394
11395 return D_O_K;
11396 }
11397 static bool doAllSolidWater()
11398 {
11399 for(int32_t i=0; i < MAXCOMBOS; ++i)
11400 {
11401 if(combo_class_buf[combobuf[i].type].water!=0)
11402 {
11403 combobuf[i].walk |= 0x0F; //Solid
11404 }
11405 }
11406 return true;
11407 }
11408 static bool doNoSolidWater()
11409 {
11410 for(int32_t i=0; i < MAXCOMBOS; ++i)
11411 {
11412 if(combo_class_buf[combobuf[i].type].water!=0)
11413 {
11414 combobuf[i].walk &= ~0x0F; //Non-solid
11415 }
11416 }
11417 return true;
11418 }
11419 int32_t onWaterSolidity()
11420 {
11421 AlertFuncDialog("Water Conversion",
11422 "Forcibly set the solidity of all 'Liquid' combos in the quest?",
11423 ""
11424 ).add_buttons(2,
11425 { "Solid", "Non-Solid", "Cancel" },
11426 { doAllSolidWater, doNoSolidWater, nullptr }
11427 ).show();
11428 return D_O_K;
11429 }
11430
11431 static bool doAllEffectSquare()
11432 {
11433 for(int32_t i=0; i < MAXCOMBOS; ++i)
11434 {
11435 combobuf[i].walk |= 0xF0; //Effect
11436 }
11437 return true;
11438 }
11439 static bool doBlankEffectSquare()
11440 {
11441 for(int32_t i=0; i < MAXCOMBOS; ++i)
11442 {
11443 if(combobuf[i].is_blank(true))
11444 {
11445 combobuf[i].walk |= 0xF0; //Effect
11446 }
11447 }
11448 return true;
11449 }
11450
11451 int32_t onEffectFix()
11452 {
11453 AlertFuncDialog("Effect Square Conversion",
11454 "Forcibly fill the green effect square of all combos in the quest?",
11455 ""
11456 ).add_buttons(2,
11457 { "All", "Blank Only", "Cancel" },
11458 { doAllEffectSquare, doBlankEffectSquare, nullptr }
11459 ).show();
11460 return D_O_K;
11461 }
11462
11463 static bool clear_green_arrival_squares()
11464 {
11465 for(mapscr& scr : TheMaps)
11466 {
11467 if(!scr.valid) continue;
11468 scr.warparrivalx = 0;
11469 scr.warparrivaly = 0;
11470 }
11471 set_qr(qr_NOARRIVALPOINT, true);
11472 return true;
11473 }
11474
11475 static bool replace_green_arrival_squares()
11476 {
11477 // Check for conflicts first
11478 bool has_conflicts = false;
11479
11480 for(mapscr& scr : TheMaps)
11481 {
11482 if(!scr.valid) continue;
11483 if(!(scr.warparrivalx || scr.warparrivaly)) continue;
11484 if(scr.warpreturnx[0] || scr.warpreturny[0])
11485 {
11486 has_conflicts = true;
11487 break;
11488 }
11489 }
11490
11491 enum
11492 {
11493 NOT_ASKED = -1,
11494 MODE_FORCE, MODE_IGNORE, MODE_FIND_IGNORE, MODE_FIND_FORCE, MODE_CANCEL
11495 };
11496 int mode = NOT_ASKED;
11497
11498 if(has_conflicts)
11499 {
11500 AlertFuncDialog("Handle Conflicts",
11501 "Warp Square A is not available for all screens that have arrival squares."
11502 " How should this be handled? (See '?' for more info)",
11503 "Overwrite A: Replace the existing warp return square A with the position of the green arrival square"
11504 "\nIgnore: Do nothing if warp return square A exists"
11505 "\nFind Space or Ignore: Choose another, unused, square to set to the position of the green arrival square."
11506 " If none are unused, 'Ignore' instead."
11507 "\nFind Space or Overwrite: Choose another, unused square to set to the position of the green arrival square."
11508 " If none are unused, 'Overwrite A' instead."
11509 "\nCancel: Don't do anything"
11510 ).add_buttons(1,
11511 { "Overwrite A", "Ignore", "Find Space or Ignore", "Find Space or Overwrite A", "Cancel" },
11512 mode
11513 ).show();
11514 if(mode == NOT_ASKED || mode == MODE_CANCEL)
11515 return false;
11516 }
11517 for(mapscr& scr : TheMaps)
11518 {
11519 if(!scr.valid) continue;
11520 if(!(scr.warparrivalx || scr.warparrivaly)) continue;
11521 int indx = 0;
11522 if(scr.warpreturnx[0] || scr.warpreturny[0])
11523 {
11524 if(mode == MODE_IGNORE) continue; // Warp A not free, so ignore
11525 if(mode != MODE_FORCE)
11526 {
11527 for(int q = 1; q < 4; ++q)
11528 {
11529 if(scr.warpreturnx[q] || scr.warpreturny[q])
11530 continue;
11531 indx = q; // Use this warp, since it's free
11532 break;
11533 }
11534 if(indx == 0 && mode == MODE_FIND_IGNORE)
11535 continue; // Nothing free, so ignore
11536 }
11537 }
11538 scr.warpreturnx[indx] = scr.warparrivalx;
11539 scr.warpreturny[indx] = scr.warparrivaly;
11540 scr.warparrivalx = 0;
11541 scr.warparrivaly = 0;
11542 }
11543 set_qr(qr_NOARRIVALPOINT, true);
11544 return true;
11545 }
11546
11547 int32_t onRemoveOldArrivalSquare()
11548 {
11549 AlertFuncDialog("Arrival Square Removal",
11550 "Clear the old green 'Arrival' squares for the whole quest?"
11551 "\n(There will be no further confirmation, and this operation cannot be undone)",
11552 ""
11553 ).add_buttons(2,
11554 { "Replace With Blue Return Square", "Clear Completely", "Cancel" },
11555 { replace_green_arrival_squares, clear_green_arrival_squares, nullptr }
11556 ).show();
11557 return D_O_K;
11558 }
11559
11560 byte* getPalPointer(int32_t pal, int32_t cset)
11561 {
11562 if (pal < 0) return colordata + CSET(cset)*3;
11563 byte* ret = colordata + CSET(pal*pdLEVEL+poLEVEL)*3;
11564 switch(cset)
11565 {
11566 case 2: case 3: case 4:
11567 return ret + CSET(cset-2)*3;
11568 case 9:
11569 return ret + CSET(3)*3;
11570 case 1:
11571 return ret + CSET(13)*3;
11572 case 5:
11573 return ret + CSET(14)*3;
11574 case 7:
11575 return ret + CSET(15)*3;
11576 case 8:
11577 return ret + CSET(16)*3;
11578 }
11579 return NULL;
11580 }
11581
11582 void copyCSet(int32_t destpal, int32_t destcset, int32_t srcpal, int32_t srccset)
11583 {
11584 byte* dest = getPalPointer(destpal, destcset);
11585 byte* src = getPalPointer(srcpal, srccset);
11586 if (dest && src)
11587 {
11588 memcpy(dest, src, 16*3);
11589 }
11590 }
11591
11592 void setColorPalette(int32_t flags, int32_t lowpal, int32_t highpal)
11593 {
11594 for (auto q = lowpal; q <= highpal; ++q)
11595 {
11596 for (auto c = 0; c < 12; ++c)
11597 {
11598 if (!(flags&(1<<c))) continue;
11599 copyCSet(q, c, -1, c);
11600 }
11601 }
11602 }
11603
11604 void setPitDamage(int32_t flags, int32_t lowcombo, int32_t highcombo, int32_t damage)
11605 {
11606 for(int32_t i=lowcombo; i < highcombo; ++i)
11607 {
11608 if((combobuf[i].type == cPITFALL && (flags & (1<<0)))
11609 || (combobuf[i].type == cWATER && !(combobuf[i].usrflags & (1<<0)) && (flags & (1<<1)))
11610 || (combobuf[i].type == cWATER && (combobuf[i].usrflags & (1<<0)) && (flags & (1<<2))))
11611 {
11612 if ((combobuf[i].type != cPITFALL || (flags & (1<<9)) || !(combobuf[i].usrflags & (1<<0)))
11613 && ((flags & (1<<8)) || combobuf[i].attributes[0] == 0))
11614 combobuf[i].attributes[0] = damage*10000;
11615 }
11616 }
11617 }
11618
11619 static DIALOG template_dlg[] =
11620 {
11621 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11622 { jwin_win_proc, 72, 80, 176+1, 116+1, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "NES Dungeon Template", NULL, NULL },
11623 { d_comboframe_proc, 178, 122+3, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
11624 { d_combo_proc, 180, 124+3, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11625 // { d_bitmap_proc, 180, 104, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11626 { jwin_radio_proc, 104+33, 128+3, 64+1, 8+1, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "Floor:", NULL, NULL },
11627 { jwin_radio_proc, 104+33, 148+3, 64+1, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "No Floor", NULL, NULL },
11628 { jwin_button_proc, 90, 172, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11629 { jwin_button_proc, 170, 172, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11630 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11631 { jwin_text_proc, 104, 102, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "This copies the contents of", NULL, NULL },
11632 { jwin_text_proc, 104, 112, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "screen 83 of the current map.", NULL, NULL },
11633 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11634 };
11635
11636 int32_t onTemplate()
11637 {
11638 static bool donethis=false;
11639
11640 if(!donethis||!(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
11641 {
11642 template_dlg[2].d1=Combo;
11643 template_dlg[2].fg=CSet;
11644 donethis=true;
11645 }
11646
11647 restore_mouse();
11648
11649 if(Map.getCurrScr()==TEMPLATE)
11650 return D_O_K;
11651
11652 // BITMAP *floor_bmp = create_bitmap_ex(8,16,16);
11653 // if(!floor_bmp) return D_O_K;
11654 template_dlg[0].dp2=get_zc_font(font_lfont);
11655 // put_combo(floor_bmp,0,0,Combo,CSet,0,0);
11656 // template_dlg[2].dp=floor_bmp;
11657
11658 large_dialog(template_dlg);
11659
11660 if(do_zqdialog(template_dlg,-1)==5)
11661 {
11662 saved=false;
11663 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
11664 Map.DoTemplateCommand((template_dlg[3].flags==D_SELECTED) ? template_dlg[2].d1 : -1, template_dlg[2].fg, screen);
11665 refresh(rMAP+rSCRMAP);
11666 }
11667
11668 // destroy_bitmap(floor_bmp);
11669 return D_O_K;
11670 }
11671
11672 int32_t d_sel_scombo_proc(int32_t msg, DIALOG *d, int32_t c)
11673 {
11674 //these are here to bypass compiler warnings about unused arguments
11675 c=c;
11676
11677 switch(msg)
11678 {
11679 case MSG_CLICK:
11680 while(gui_mouse_b())
11681 {
11682 int32_t x = zc_min(zc_max(gui_mouse_x() - d->x,0)>>4, 15);
11683 int32_t y = zc_min(zc_max(gui_mouse_y() - d->y,0)&0xF0, 160);
11684
11685 if(x+y != d->d1)
11686 {
11687 d->d1 = x+y;
11688 custom_vsync();
11689 d_sel_scombo_proc(MSG_DRAW,d,0);
11690 }
11691 }
11692
11693 break;
11694
11695 case MSG_DRAW:
11696 {
11697 blit((BITMAP*)(d->dp),screen,0,0,d->x,d->y,d->w,d->h);
11698 int32_t x = d->x + (((d->d1)&15)<<4);
11699 int32_t y = d->y + ((d->d1)&0xF0);
11700 rect(screen,x,y,x+15,y+15,vc(15));
11701 }
11702 break;
11703 }
11704
11705 return D_O_K;
11706 }
11707
11708 static DIALOG cflag_dlg[] =
11709 {
11710 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
11711 12 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
11712 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11713 12 { jwin_abclist_proc, 72-12-4, 60+4, 176+24+8, 92+3, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
11714 12 { jwin_button_proc, 70, 163, 51, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11715 12 { jwin_button_proc, 190, 163, 51, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11716 12 { jwin_button_proc, 130, 163, 51, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Help", NULL, NULL },
11717 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11718 };
11719
11720
11721 void questrev_help()
11722 {
11723 jwin_alert("Help","The revision number of your quest.",NULL,NULL,"O&K",NULL,'k',16,get_zc_font(font_lfont));
11724 }
11725
11726 void questminrev_help()
11727 {
11728 jwin_alert("Help","If a player's saved game was from a revision less than the minimum", "revision, they have to restart from the beginning.", "This is useful if you make major changes to your quest.","O&K",NULL,'k',16,get_zc_font(font_lfont));
11729 }
11730
11731 int32_t select_cflag(const char *prompt,int32_t flag)
11732 {
11733 cflag_dlg[0].dp=(void *)prompt;
11734 cflag_dlg[0].dp2=get_zc_font(font_lfont);
11735 GUI::ListData ld = GUI::ZCListData::mapflag(numericalFlags, true);
11736 ListData select_cflag_list = ld.getJWin(&font);
11737 int32_t index = ld.findIndex(flag);
11738 cflag_dlg[2].d1=index;
11739 cflag_dlg[2].dp=(void *) &select_cflag_list;
11740
11741 large_dialog(cflag_dlg);
11742
11743 int32_t ret;
11744
11745 do
11746 {
11747 ret=do_zqdialog(cflag_dlg,2);
11748
11749 if(ret==5)
11750 {
11751 cflag_help(ld.getValue(cflag_dlg[2].d1));
11752 }
11753 }
11754 while(ret==5);
11755
11756 if(ret==0||ret==4)
11757 {
11758 position_mouse_z(0);
11759 return -1;
11760 }
11761
11762 return ld.getValue(cflag_dlg[2].d1);
11763 }
11764
11765 int32_t select_flag(int32_t &f)
11766 {
11767 int32_t ret=select_cflag("Flag Type",f);
11768
11769 if(ret>=0)
11770 {
11771 f=ret;
11772 return true;
11773 }
11774
11775 return false;
11776 }
11777
11778 int32_t d_scombo_proc(int32_t msg,DIALOG *d,int32_t c)
11779 {
11780 //these are here to bypass compiler warnings about unused arguments
11781 c=c;
11782
11783 switch(msg)
11784 {
11785 case MSG_CLICK:
11786 {
11787 int32_t c2=d->d1;
11788 int32_t cs=d->fg;
11789 int32_t f=d->d2;
11790
11791 if(d->bg==1 || (CHECK_CTRL_CMD))
11792 {
11793 while(gui_mouse_b())
11794 {
11795 /* do nothing */
11796 rest(1);
11797 }
11798
11799 if(select_flag(f))
11800 {
11801 d->d2=f;
11802
11803 }
11804 }
11805 else if(key[KEY_LSHIFT])
11806 {
11807 if(gui_mouse_b()&1)
11808 {
11809 d->d1++;
11810
11811 if(d->d1>=MAXCOMBOS) d->d1=0;
11812 }
11813 else if(gui_mouse_b()&2)
11814 {
11815 d->d1--;
11816
11817 if(d->d1<0) d->d1=MAXCOMBOS-1;
11818 }
11819 }
11820 else if(key[KEY_RSHIFT])
11821 {
11822 if(gui_mouse_b()&1)
11823 {
11824 d->fg++;
11825
11826 if(d->fg>11) d->fg=0;
11827 }
11828 else if(gui_mouse_b()&2)
11829 {
11830 d->fg--;
11831
11832 if(d->fg<0) d->fg=11;
11833 }
11834 }
11835 else if(key[KEY_ALT])
11836 {
11837 if(gui_mouse_b()&1)
11838 {
11839 d->d1 = Combo;
11840 d->fg = CSet;
11841 }
11842 }
11843 else
11844 {
11845 if(select_combo_2(c2, cs))
11846 {
11847 d->d1=c2;
11848 d->fg=cs;
11849 }
11850 }
11851
11852 return D_REDRAW;
11853 }
11854 break;
11855
11856 case MSG_DRAW:
11857 d->w = 32;
11858 d->h = 32;
11859
11860 BITMAP *buf = create_bitmap_ex(8,16,16);
11861 BITMAP *bigbmp = create_bitmap_ex(8,d->w,d->h);
11862
11863 if(buf && bigbmp)
11864 {
11865 clear_bitmap(buf);
11866
11867 if(d->bg) //flags only
11868 {
11869 put_flag(buf,0,0,d->d2);
11870 }
11871 else if(d->d1)
11872 {
11873 putcombo(buf,0,0,d->d1,d->fg);
11874
11875 if(Flags&cFLAGS)
11876 put_flags(buf,0,0,d->d1,d->fg,cFLAGS,d->d2);
11877 }
11878
11879 stretch_blit(buf, bigbmp, 0,0, 16, 16, 0, 0, d->w, d->h);
11880 destroy_bitmap(buf);
11881 blit(bigbmp,screen,0,0,d->x-1,d->y-1,d->w,d->h);
11882 destroy_bitmap(bigbmp);
11883 }
11884
11885
11886 /*BITMAP *buf = create_bitmap_ex(8,16,16);
11887 if(buf)
11888 {
11889 clear_bitmap(buf);
11890 if(d->d1)
11891 putcombo(buf,0,0,d->d1,d->fg);
11892
11893 blit(buf,screen,0,0,d->x,d->y,d->w,d->h);
11894 destroy_bitmap(buf);
11895 }*/
11896 break;
11897 }
11898
11899 return D_O_K;
11900 }
11901
11902 /*int32_t d_scombo2_proc(int32_t msg, DIALOG *d, int32_t c)
11903 {
11904 //these are here to bypass compiler warnings about unused arguments
11905 c=c;
11906
11907 switch(msg)
11908 {
11909 case MSG_CLICK:
11910 if (CHECK_CTRL_CMD)
11911 {
11912 select_scombo(d->d1);
11913 }
11914 else
11915 {
11916 select_scombo(d->d1);
11917 }
11918 d_scombo_proc(MSG_DRAW,d,0);
11919 break;
11920
11921
11922 case MSG_DRAW:
11923 BITMAP *buf = create_bitmap_ex(8,16,16);
11924 if(buf)
11925 {
11926 clear_bitmap(buf);
11927 Map.draw_secret2(buf,d->d1);
11928 blit(buf,screen,0,0,d->x,d->y,16,16);
11929 destroy_bitmap(buf);
11930 }
11931 break;
11932 }
11933
11934 return D_O_K;
11935 }*/
11936
11937 int32_t onSecretF();
11938
11939 static int32_t secret_burn_list[] =
11940 {
11941 // dialog control number
11942 4, 5, 6, 7, 48, 49, 50, 51, 92, 93, 94, 95, -1
11943 };
11944
11945 static int32_t secret_arrow_list[] =
11946 {
11947 // dialog control number
11948 8, 9, 10, 52, 53, 54, 96, 97, 98, -1
11949 };
11950
11951 static int32_t secret_bomb_list[] =
11952 {
11953 // dialog control number
11954 11, 12, 55, 56, 99, 100, -1
11955 };
11956
11957 static int32_t secret_boomerang_list[] =
11958 {
11959 // dialog control number
11960 13, 14, 15, 57, 58, 59, 101, 102, 103, -1
11961 };
11962
11963 static int32_t secret_magic_list[] =
11964 {
11965 // dialog control number
11966 16, 17, 60, 61, 104, 105, -1
11967 };
11968
11969 static int32_t secret_sword_list[] =
11970 {
11971 // dialog control number
11972 18, 19, 20, 21, 22, 23, 24, 25, 62, 63, 64, 65, 66, 67, 68, 69, 106, 107, 108, 109, 110, 111, 112, 113, -1
11973 };
11974
11975 static int32_t secret_misc_list[] =
11976 {
11977 // dialog control number
11978 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, -1
11979 };
11980
11981 static TABPANEL secret_tabs[] =
11982 {
11983 // (text)
11984 { (char *)"Burn", D_SELECTED, secret_burn_list, 0, NULL },
11985 { (char *)"Arrow", 0, secret_arrow_list, 0, NULL },
11986 { (char *)"Bomb", 0, secret_bomb_list, 0, NULL },
11987 { (char *)"Boomerang", 0, secret_boomerang_list, 0, NULL },
11988 { (char *)"Magic", 0, secret_magic_list, 0, NULL },
11989 { (char *)"Sword", 0, secret_sword_list, 0, NULL },
11990 { (char *)"Misc", 0, secret_misc_list, 0, NULL },
11991 { NULL, 0, NULL, 0, NULL }
11992 };
11993
11994 static DIALOG secret_dlg[] =
11995 {
11996 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
11997 { jwin_win_proc, 0, 0, 301, 212, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
11998 { jwin_tab_proc, 6, 25, 289, 156, 0, 0, 0, 0, 0, 0, (void *) secret_tabs, NULL, (void *)secret_dlg },
11999 { jwin_button_proc, 80, 187, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
12000 { jwin_button_proc, 160, 187, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
12001 // 4
12002 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Any Fire", NULL, NULL },
12003 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Strong Fire", NULL, NULL },
12004 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Fire", NULL, NULL },
12005 { jwin_text_proc, 12, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Divine Fire", NULL, NULL },
12006 //8
12007 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wooden Arrow", NULL, NULL },
12008 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Silver Arrow", NULL, NULL },
12009 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Golden Arrow", NULL, NULL },
12010 //11
12011 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Bomb", NULL, NULL },
12012 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Super Bomb", NULL, NULL },
12013 //13
12014 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wooden Boomerang", NULL, NULL },
12015 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Boomerang", NULL, NULL },
12016 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Fire Boomerang", NULL, NULL },
12017 //16
12018 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wand Magic", NULL, NULL },
12019 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Reflected Magic", NULL, NULL },
12020 //18
12021 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
12022 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "White Sword", NULL, NULL },
12023 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Sword", NULL, NULL },
12024 { jwin_text_proc, 12, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Master Sword", NULL, NULL },
12025 { jwin_text_proc, 160, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Sword Beam", NULL, NULL },
12026 { jwin_text_proc, 160, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "White Sword Beam", NULL, NULL },
12027 { jwin_text_proc, 160, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Sword Beam", NULL, NULL },
12028 { jwin_text_proc, 160, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Master Sword Beam", NULL, NULL },
12029 //26
12030 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Stairs", NULL, NULL },
12031 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Reflected Fireball", NULL, NULL },
12032 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
12033 { jwin_text_proc, 12, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wand", NULL, NULL },
12034 { jwin_text_proc, 12, 141, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
12035 { jwin_text_proc, 12, 163, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Any Weapon", NULL, NULL },
12036 //32
12037 { jwin_ctext_proc, 235, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Flags 16-31", NULL, NULL },
12038 { jwin_text_proc, 87, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Secrets->Next (Flag only)", NULL, NULL },
12039 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 03", NULL, NULL },
12040 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 04", NULL, NULL },
12041 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 05", NULL, NULL },
12042 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 06", NULL, NULL },
12043 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 07", NULL, NULL },
12044 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 08", NULL, NULL },
12045 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 09", NULL, NULL },
12046 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 10", NULL, NULL },
12047 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 11", NULL, NULL },
12048 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 12", NULL, NULL },
12049 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 13", NULL, NULL },
12050 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 14", NULL, NULL },
12051 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 15", NULL, NULL },
12052 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 16", NULL, NULL },
12053 //48 (burn)
12054 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12055 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12056 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12057 { jwin_frame_proc, 108, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12058 //52 (arrow)
12059 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12060 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12061 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12062 //55 (bomb)
12063 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12064 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12065 //57 (boomerang)
12066 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12067 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12068 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12069 //60 (magic)
12070 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12071 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12072 //62 (sword)
12073 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12074 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12075 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12076 { jwin_frame_proc, 108, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12077 { jwin_frame_proc, 256, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12078 { jwin_frame_proc, 256, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12079 { jwin_frame_proc, 256, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12080 { jwin_frame_proc, 256, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12081 //70 (misc)
12082 { jwin_frame_proc, 63, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12083 { jwin_frame_proc, 63, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12084 { jwin_frame_proc, 63, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12085 { jwin_frame_proc, 63, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12086 { jwin_frame_proc, 63, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12087 { jwin_frame_proc, 63, 157, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12088 //76 (16-32)
12089 { jwin_frame_proc, 192, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12090 { jwin_frame_proc, 214, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12091 { jwin_frame_proc, 236, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12092 { jwin_frame_proc, 258, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12093 { jwin_frame_proc, 192, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12094 { jwin_frame_proc, 214, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12095 { jwin_frame_proc, 236, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12096 { jwin_frame_proc, 258, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12097 { jwin_frame_proc, 192, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12098 { jwin_frame_proc, 214, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12099 { jwin_frame_proc, 236, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12100 { jwin_frame_proc, 258, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12101 { jwin_frame_proc, 192, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12102 { jwin_frame_proc, 214, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12103 { jwin_frame_proc, 236, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12104 { jwin_frame_proc, 258, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12105
12106 //92 (burn)
12107 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12108 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12109 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12110 { d_scombo_proc, 110, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12111 //96 (arrow)
12112 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12113 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12114 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12115 //99 (bomb)
12116 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12117 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12118 //101 (boomerang)
12119 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12120 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12121 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12122 //104 (magic)
12123 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12124 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12125 //106 (sword)
12126 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12127 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12128 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12129 { d_scombo_proc, 110, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12130 { d_scombo_proc, 258, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12131 { d_scombo_proc, 258, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12132 { d_scombo_proc, 258, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12133 { d_scombo_proc, 258, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12134 //114 (misc)
12135 { d_scombo_proc, 65, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12136 { d_scombo_proc, 65, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12137 { d_scombo_proc, 65, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12138 { d_scombo_proc, 65, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12139 { d_scombo_proc, 65, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12140 { d_scombo_proc, 65, 159, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12141 //120 (16-32)
12142 { d_scombo_proc, 194, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12143 { d_scombo_proc, 216, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12144 { d_scombo_proc, 238, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12145 { d_scombo_proc, 260, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12146 { d_scombo_proc, 194, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12147 { d_scombo_proc, 216, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12148 { d_scombo_proc, 238, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12149 { d_scombo_proc, 260, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12150 { d_scombo_proc, 194, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12151 { d_scombo_proc, 216, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12152 { d_scombo_proc, 238, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12153 { d_scombo_proc, 260, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12154 { d_scombo_proc, 194, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12155 { d_scombo_proc, 216, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12156 { d_scombo_proc, 238, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12157 { d_scombo_proc, 260, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12158 //136 Secrets->Next
12159 { jwin_frame_proc, 158, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12160 { d_scombo_proc, 160, 49, 16, 16, 0, 1, 0, 0, 0, 0, NULL, NULL, NULL },
12161 //138
12162 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
12163 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 'f', 0, 0, 0, (void *) onSecretF, NULL, NULL },
12164 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12165 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12166 };
12167
12168 int32_t onSecretF()
12169 {
12170 Flags^=cFLAGS;
12171 object_message(secret_dlg+1, MSG_DRAW, 0);
12172 return D_O_K;
12173 }
12174
12175
12176 int32_t onSecretCombo()
12177 {
12178 secret_dlg[0].dp2=get_zc_font(font_lfont);
12179
12180
12181 mapscr *s;
12182
12183 if(CurrentLayer==0)
12184 {
12185 s=Map.CurrScr();
12186 }
12187 else
12188 {
12189 // s=TheMaps[(Map.CurrScr()->layermap[CurrentLayer-1]-1)*MAPSCRS+(Map.CurrScr()->layerscreen[CurrentLayer-1])];
12190 s=Map.AbsoluteScr((Map.CurrScr()->layermap[CurrentLayer-1]-1), (Map.CurrScr()->layerscreen[CurrentLayer-1]));
12191 }
12192 if(!s) return D_O_K;
12193
12194 char secretcombonumstr[27];
12195 sprintf(secretcombonumstr,"Secret Combos for Layer %d", CurrentLayer);
12196 secret_dlg[0].dp = secretcombonumstr;
12197
12198 secret_dlg[92].d1 = s->secretcombo[sBCANDLE];
12199 secret_dlg[92].fg = s->secretcset[sBCANDLE];
12200 secret_dlg[92].d2 = s->secretflag[sBCANDLE];
12201
12202 secret_dlg[93].d1 = s->secretcombo[sRCANDLE];
12203 secret_dlg[93].fg = s->secretcset[sRCANDLE];
12204 secret_dlg[93].d2 = s->secretflag[sRCANDLE];
12205
12206 secret_dlg[94].d1 = s->secretcombo[sWANDFIRE];
12207 secret_dlg[94].fg = s->secretcset[sWANDFIRE];
12208 secret_dlg[94].d2 = s->secretflag[sWANDFIRE];
12209
12210 secret_dlg[95].d1 = s->secretcombo[sDIVINEFIRE];
12211 secret_dlg[95].fg = s->secretcset[sDIVINEFIRE];
12212 secret_dlg[95].d2 = s->secretflag[sDIVINEFIRE];
12213
12214 secret_dlg[96].d1 = s->secretcombo[sARROW];
12215 secret_dlg[96].fg = s->secretcset[sARROW];
12216 secret_dlg[96].d2 = s->secretflag[sARROW];
12217
12218 secret_dlg[97].d1 = s->secretcombo[sSARROW];
12219 secret_dlg[97].fg = s->secretcset[sSARROW];
12220 secret_dlg[97].d2 = s->secretflag[sSARROW];
12221
12222 secret_dlg[98].d1 = s->secretcombo[sGARROW];
12223 secret_dlg[98].fg = s->secretcset[sGARROW];
12224 secret_dlg[98].d2 = s->secretflag[sGARROW];
12225
12226 secret_dlg[99].d1 = s->secretcombo[sBOMB];
12227 secret_dlg[99].fg = s->secretcset[sBOMB];
12228 secret_dlg[99].d2 = s->secretflag[sBOMB];
12229
12230 secret_dlg[100].d1 = s->secretcombo[sSBOMB];
12231 secret_dlg[100].fg = s->secretcset[sSBOMB];
12232 secret_dlg[100].d2 = s->secretflag[sSBOMB];
12233
12234 for(int32_t i=0; i<3; i++)
12235 {
12236 secret_dlg[101+i].d1 = s->secretcombo[sBRANG+i];
12237 secret_dlg[101+i].fg = s->secretcset[sBRANG+i];
12238 secret_dlg[101+i].d2 = s->secretflag[sBRANG+i];
12239 }
12240
12241 for(int32_t i=0; i<2; i++)
12242 {
12243 secret_dlg[104+i].d1 = s->secretcombo[sWANDMAGIC+i];
12244 secret_dlg[104+i].fg = s->secretcset[sWANDMAGIC+i];
12245 secret_dlg[104+i].d2 = s->secretflag[sWANDMAGIC+i];
12246 }
12247
12248 for(int32_t i=0; i<8; i++)
12249 {
12250 secret_dlg[106+i].d1 = s->secretcombo[sSWORD+i];
12251 secret_dlg[106+i].fg = s->secretcset[sSWORD+i];
12252 secret_dlg[106+i].d2 = s->secretflag[sSWORD+i];
12253 }
12254
12255 secret_dlg[114].d1 = s->secretcombo[sSTAIRS];
12256 secret_dlg[114].fg = s->secretcset[sSTAIRS];
12257 secret_dlg[114].d2 = s->secretflag[sSTAIRS];
12258
12259 secret_dlg[115].d1 = s->secretcombo[sREFFIREBALL];
12260 secret_dlg[115].fg = s->secretcset[sREFFIREBALL];
12261 secret_dlg[115].d2 = s->secretflag[sREFFIREBALL];
12262
12263 for(int32_t i=0; i<4; i++)
12264 {
12265 secret_dlg[116+i].d1 = s->secretcombo[sHOOKSHOT+i];
12266 secret_dlg[116+i].fg = s->secretcset[sHOOKSHOT+i];
12267 secret_dlg[116+i].d2 = s->secretflag[sHOOKSHOT+i];
12268 }
12269
12270 for(int32_t i=0; i<16; i++)
12271 {
12272 secret_dlg[120+i].d1 = s->secretcombo[sSECRET01+i];
12273 secret_dlg[120+i].fg = s->secretcset[sSECRET01+i];
12274 secret_dlg[120+i].d2 = s->secretflag[sSECRET01+i];
12275 }
12276
12277 //Sec->Next doesn't have a combo/cset value associated
12278 secret_dlg[137].d1 = 0;
12279 secret_dlg[137].fg = 0;
12280 secret_dlg[137].d2 = s->secretflag[sSECNEXT];
12281
12282 large_dialog(secret_dlg,1.75);
12283
12284 for(int32_t q = 0; secret_dlg[q].proc != NULL; ++q)
12285 {
12286 if(secret_dlg[q].proc == jwin_frame_proc)
12287 secret_dlg[q].w = secret_dlg[q].h = 36;
12288 }
12289
12290 go();
12291
12292 if(do_zqdialog(secret_dlg,3) == 2)
12293 {
12294 saved = false;
12295 s->secretcombo[sBCANDLE] = secret_dlg[92].d1;
12296 s->secretcset[sBCANDLE] = secret_dlg[92].fg;
12297 s->secretflag[sBCANDLE] = secret_dlg[92].d2;
12298
12299 s->secretcombo[sRCANDLE] = secret_dlg[93].d1;
12300 s->secretcset[sRCANDLE] = secret_dlg[93].fg;
12301 s->secretflag[sRCANDLE] = secret_dlg[93].d2;
12302
12303 s->secretcombo[sWANDFIRE] = secret_dlg[94].d1;
12304 s->secretcset[sWANDFIRE] = secret_dlg[94].fg;
12305 s->secretflag[sWANDFIRE] = secret_dlg[94].d2;
12306
12307 s->secretcombo[sDIVINEFIRE] = secret_dlg[95].d1;
12308 s->secretcset[sDIVINEFIRE] = secret_dlg[95].fg;
12309 s->secretflag[sDIVINEFIRE] = secret_dlg[95].d2;
12310
12311 s->secretcombo[sARROW] = secret_dlg[96].d1;
12312 s->secretcset[sARROW] = secret_dlg[96].fg;
12313 s->secretflag[sARROW] = secret_dlg[96].d2;
12314
12315 s->secretcombo[sSARROW] = secret_dlg[97].d1;
12316 s->secretcset[sSARROW] = secret_dlg[97].fg;
12317 s->secretflag[sSARROW] = secret_dlg[97].d2;
12318
12319 s->secretcombo[sGARROW] = secret_dlg[98].d1;
12320 s->secretcset[sGARROW] = secret_dlg[98].fg;
12321 s->secretflag[sGARROW] = secret_dlg[98].d2;
12322
12323 s->secretcombo[sBOMB] = secret_dlg[99].d1;
12324 s->secretcset[sBOMB] = secret_dlg[99].fg;
12325 s->secretflag[sBOMB] = secret_dlg[99].d2;
12326
12327 s->secretcombo[sSBOMB] = secret_dlg[100].d1;
12328 s->secretcset[sSBOMB] = secret_dlg[100].fg;
12329 s->secretflag[sSBOMB] = secret_dlg[100].d2;
12330
12331 for(int32_t i=0; i<3; i++)
12332 {
12333 s->secretcombo[sBRANG+i] = secret_dlg[101+i].d1;
12334 s->secretcset[sBRANG+i] = secret_dlg[101+i].fg;
12335 s->secretflag[sBRANG+i] = secret_dlg[101+i].d2;
12336 }
12337
12338 for(int32_t i=0; i<2; i++)
12339 {
12340 s->secretcombo[sWANDMAGIC+i] = secret_dlg[104+i].d1;
12341 s->secretcset[sWANDMAGIC+i] = secret_dlg[104+i].fg;
12342 s->secretflag[sWANDMAGIC+i] = secret_dlg[104+i].d2;
12343 }
12344
12345 for(int32_t i=0; i<8; i++)
12346 {
12347 s->secretcombo[sSWORD+i] = secret_dlg[106+i].d1;
12348 s->secretcset[sSWORD+i] = secret_dlg[106+i].fg;
12349 s->secretflag[sSWORD+i] = secret_dlg[106+i].d2;
12350 }
12351
12352 s->secretcombo[sSTAIRS] = secret_dlg[114].d1;
12353 s->secretcset[sSTAIRS] = secret_dlg[114].fg;
12354 s->secretflag[sSTAIRS] = secret_dlg[114].d2;
12355
12356 s->secretcombo[sREFFIREBALL] = secret_dlg[115].d1;
12357 s->secretcset[sREFFIREBALL] = secret_dlg[115].fg;
12358 s->secretflag[sREFFIREBALL] = secret_dlg[115].d2;
12359
12360 for(int32_t i=0; i<4; i++)
12361 {
12362 s->secretcombo[sHOOKSHOT+i] = secret_dlg[116+i].d1;
12363 s->secretcset[sHOOKSHOT+i] = secret_dlg[116+i].fg;
12364 s->secretflag[sHOOKSHOT+i] = secret_dlg[116+i].d2;
12365 }
12366
12367 for(int32_t i=0; i<16; i++)
12368 {
12369 s->secretcombo[sSECRET01+i] = secret_dlg[120+i].d1;
12370 s->secretcset[sSECRET01+i] = secret_dlg[120+i].fg;
12371 s->secretflag[sSECRET01+i] = secret_dlg[120+i].d2;
12372 }
12373 s->secretflag[sSECNEXT] = secret_dlg[137].d2;
12374
12375 }
12376
12377 comeback();
12378 return D_O_K;
12379 }
12380
12381 static DIALOG under_dlg[] =
12382 {
12383 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
12384 { jwin_win_proc, 72, 60, 176+1,120+1,vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12385 { jwin_text_proc, 115, 83, 20, 20, vc(14), vc(1), 0, 0, 0, 0, (void *) "Current", NULL, NULL },
12386 { d_comboframe_proc, 122, 92, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12387 { d_combo_proc, 124, 94, 16, 16, 0, 0, 0, D_NOCLICK, 0, 0, NULL, NULL, NULL },
12388 { jwin_text_proc, 184, 83, 20, 20, vc(14), vc(1), 0, 0, 0, 0, (void *) "New", NULL, NULL },
12389 { d_comboframe_proc, 182, 92, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12390 { d_combo_proc, 184, 94, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12391 { jwin_button_proc, 90, 124, 61, 21, vc(14), vc(1), 's', D_EXIT, 0, 0, (void *) "&Set", NULL, NULL },
12392 { jwin_button_proc, 170, 124, 61, 21, vc(14), vc(1), 'c', D_EXIT, 0, 0, (void *) "&Cancel", NULL, NULL },
12393 { jwin_button_proc, 90, 152, 61, 21, vc(14), vc(1), 'a', D_EXIT, 0, 0, (void *) "Set &All", NULL, NULL },
12394 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
12395 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12396 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12397 };
12398
12399 int32_t onUnderCombo()
12400 {
12401 char titlebuf[64];
12402 sprintf(titlebuf, "Under Combo (Layer %d)", CurrentLayer);
12403 under_dlg[0].dp = titlebuf;
12404 under_dlg[0].dp2 = get_zc_font(font_lfont);
12405 mapscr* scr;
12406 if(CurrentLayer==0)
12407 {
12408 scr=Map.CurrScr();
12409 }
12410 else
12411 {
12412 auto map=Map.CurrScr()->layermap[CurrentLayer-1]-1;
12413 auto screen=Map.CurrScr()->layerscreen[CurrentLayer-1];
12414 scr = Map.AbsoluteScr(map,screen);
12415 }
12416 if(!scr) return D_O_K;
12417
12418 under_dlg[3].d1=scr->undercombo;
12419 under_dlg[3].fg=scr->undercset;
12420
12421 under_dlg[6].d1=Combo;
12422 under_dlg[6].fg=CSet;
12423
12424 large_dialog(under_dlg);
12425 // Doesn't place "New" and "Current" text too well
12426 under_dlg[1].x=342;
12427 under_dlg[4].x=438;
12428
12429 int32_t ret = do_zqdialog(under_dlg,-1);
12430
12431 if(ret==7)
12432 {
12433 saved=false;
12434 scr->undercombo = under_dlg[6].d1;
12435 scr->undercset = under_dlg[6].fg;
12436 }
12437
12438 if(ret==9 && jwin_alert("Confirm Overwrite","Set all Under Combos","on this map?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
12439 {
12440 saved=false;
12441
12442 for(int32_t i=0; i<128; i++)
12443 {
12444 Map.Scr(i)->undercombo = under_dlg[6].d1;
12445 Map.Scr(i)->undercset = under_dlg[6].fg;
12446 }
12447 }
12448
12449 return D_O_K;
12450 }
12451
12452 static DIALOG list_dlg[] =
12453 {
12454 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
12455 12 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12456 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12457 12 { jwin_list_proc, 72-12-4, 60+4, 176+24+8, 92+3, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12458 12 { jwin_button_proc, 90, 163, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
12459 12 { jwin_button_proc, 170, 163, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
12460 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12461 };
12462
12463 /*
12464 typedef struct item_struct {
12465 char *s;
12466 int32_t i;
12467 } item_struct;
12468 */
12469 item_struct bii[MAXITEMS+1];
12470 int32_t bii_cnt=-1;
12471
12472 void build_bii_list(bool usenone)
12473 {
12474 int32_t start=bii_cnt=0;
12475
12476 if(usenone)
12477 {
12478 bii[0].s = (char *)"(None)";
12479 bii[0].i = -2;
12480 bii_cnt=start=1;
12481 }
12482
12483 for(int32_t i=0; i<MAXITEMS; i++)
12484 {
12485 bii[bii_cnt].s = item_string[i];
12486 bii[bii_cnt].i = i;
12487 ++bii_cnt;
12488 }
12489
12490 for(int32_t i=start; i<bii_cnt-1; i++)
12491 {
12492 for(int32_t j=i+1; j<bii_cnt; j++)
12493 {
12494 if(stricmp(bii[i].s,bii[j].s)>0 && strcmp(bii[j].s,""))
12495 {
12496 zc_swap(bii[i],bii[j]);
12497 }
12498 }
12499 }
12500 }
12501
12502
12503 const char *itemlist(int32_t index, int32_t *list_size)
12504 {
12505 if(index<0)
12506 {
12507 *list_size = bii_cnt;
12508 return NULL;
12509 }
12510
12511 return bii[index].s;
12512 }
12513 const char *itemlist_num(int32_t index, int32_t *list_size)
12514 {
12515 if(index<0)
12516 {
12517 *list_size = bii_cnt;
12518 return NULL;
12519 }
12520 static char biin_buf[64+6];
12521 if(bii[index].i < 0)
12522 return bii[index].s;
12523 sprintf(biin_buf, "%s (%03d)", bii[index].s, bii[index].i);
12524 return biin_buf;
12525 }
12526
12527 // disable items on dmaps stuff
12528 int32_t DI[MAXITEMS];
12529 int32_t nDI;
12530
12531 void initDI(int32_t index)
12532 {
12533 int32_t j=0;
12534
12535 for(int32_t i=0; i<MAXITEMS; i++)
12536 {
12537 int32_t index1=bii[i].i; // true index of item in dmap's DI list
12538
12539 if(DMaps[index].disableditems[index1])
12540 {
12541 DI[j]=i;
12542 j++;
12543 }
12544 }
12545
12546 nDI=j;
12547
12548 for(int32_t i=j; i<MAXITEMS; i++) DI[j]=0;
12549
12550 return;
12551 }
12552
12553 void insertDI(int32_t id, int32_t index)
12554 {
12555 int32_t trueid=bii[id].i;
12556 DMaps[index].disableditems[trueid] |= 1; //bit set
12557 initDI(index);
12558 return;
12559 }
12560
12561 void deleteDI(int32_t id, int32_t index)
12562 {
12563 int32_t i=DI[id];
12564 int32_t trueid=bii[i].i;
12565 DMaps[index].disableditems[trueid] &= (~1); // bit clear
12566 initDI(index);
12567 return;
12568 }
12569
12570 const char *DIlist(int32_t index, int32_t *list_size)
12571 {
12572 if(index<0)
12573 {
12574 *list_size = nDI;
12575 return NULL;
12576 }
12577
12578 int32_t i=DI[index];
12579 return bii[i].s;
12580
12581 }
12582
12583 weapon_struct biw[MAXWPNS];
12584 int32_t biw_cnt=-1;
12585
12586 void build_biw_list()
12587 {
12588 int32_t start=biw_cnt=0;
12589
12590 for(int32_t i=start; i<MAXWPNS; i++)
12591 {
12592 biw[biw_cnt].s = (char *)weapon_string[i];
12593 biw[biw_cnt].i = i;
12594 ++biw_cnt;
12595 }
12596
12597 for(int32_t i=start; i<biw_cnt-1; i++)
12598 {
12599 for(int32_t j=i+1; j<biw_cnt; j++)
12600 if(stricmp(biw[i].s,biw[j].s)>0 && strcmp(biw[j].s,""))
12601 zc_swap(biw[i],biw[j]);
12602 }
12603 }
12604
12605 const char *weaponlist(int32_t index, int32_t *list_size)
12606 {
12607 if(index<0)
12608 {
12609 *list_size = biw_cnt;
12610 return NULL;
12611 }
12612
12613 return biw[index].s;
12614 }
12615 const char *weaponlist_num(int32_t index, int32_t *list_size)
12616 {
12617 if(index<0)
12618 {
12619 *list_size = biw_cnt;
12620 return NULL;
12621 }
12622 static char biwn_buf[64+6];
12623 if(biw[index].i < 0)
12624 return biw[index].s;
12625 sprintf(biwn_buf, "%s (%03d)", biw[index].s, biw[index].i);
12626 return biwn_buf;
12627 }
12628 int32_t writeoneweapon(PACKFILE *f, int32_t index)
12629 {
12630 dword section_version=V_WEAPONS;
12631 int32_t zversion = ZELDA_VERSION;
12632 int32_t zbuild = VERSION_BUILD;
12633 int32_t iid = biw[index].i;
12634 al_trace("Writing Weapon Sprite .zwpnspr file for weapon id: %d\n", iid);
12635
12636 //section version info
12637 if(!p_iputl(zversion,f))
12638 {
12639 return 0;
12640 }
12641 if(!p_iputl(zbuild,f))
12642 {
12643 return 0;
12644 }
12645 if(!p_iputw(section_version,f))
12646 {
12647 return 0;
12648 }
12649
12650 if(!write_deprecated_section_cversion(section_version, f))
12651 {
12652 return 0;
12653 }
12654
12655 //weapon string
12656
12657 if(!pfwrite((char *)weapon_string[iid], 64, f))
12658 {
12659 return 0;
12660 }
12661
12662 if(!p_putc(wpnsbuf[iid].misc,f))
12663 {
12664 return 0;
12665 }
12666
12667 if(!p_putc(wpnsbuf[iid].csets,f))
12668 {
12669 return 0;
12670 }
12671
12672 if(!p_putc(wpnsbuf[iid].frames,f))
12673 {
12674 return 0;
12675 }
12676
12677 if(!p_putc(wpnsbuf[iid].speed,f))
12678 {
12679 return 0;
12680 }
12681
12682 if(!p_putc(wpnsbuf[iid].type,f))
12683 {
12684 return 0;
12685 }
12686
12687 if(!p_iputw(wpnsbuf[iid].script,f))
12688 {
12689 return 0;
12690 }
12691
12692 //2.55 starts here
12693 if(!p_iputl(wpnsbuf[iid].tile,f))
12694 {
12695 return 0;
12696 }
12697
12698 return 1;
12699 }
12700
12701
12702 int32_t readoneweapon(PACKFILE *f, int32_t index)
12703 {
12704 dword section_version = 0;
12705 int32_t zversion = 0;
12706 int32_t zbuild = 0;
12707 wpndata tempwpnspr;
12708 memset(&tempwpnspr, 0, sizeof(wpndata));
12709
12710
12711 //char dmapstring[64]={0};
12712 //section version info
12713 if(!p_igetl(&zversion,f))
12714 {
12715 return 0;
12716 }
12717 if(!p_igetl(&zbuild,f))
12718 {
12719 return 0;
12720 }
12721 if(!p_igetw(&section_version,f))
12722 {
12723 return 0;
12724 }
12725 if(!read_deprecated_section_cversion(f))
12726 {
12727 return 0;
12728 }
12729 al_trace("readoneweapon section_version: %d\n", section_version);
12730
12731 if ( zversion > ZELDA_VERSION )
12732 {
12733 al_trace("Cannot read .zwpnspr packfile made in ZC version (%x) in this version of ZC (%x)\n", zversion, ZELDA_VERSION);
12734 return 0;
12735 }
12736
12737 else if ( ( section_version > V_WEAPONS ) )
12738 {
12739 al_trace("Cannot read .zwpnspr packfile made using V_WEAPONS (%d)\n", section_version);
12740 return 0;
12741
12742 }
12743 else
12744 {
12745 al_trace("Reading a .zwpnspr packfile made in ZC Version: %x, Build: %d\n", zversion, zbuild);
12746 }
12747
12748 char tmp_wpn_name[64];
12749 memset(tmp_wpn_name,0,64);
12750 if(!pfread(&tmp_wpn_name, 64, f))
12751 {
12752 return 0;
12753 }
12754
12755 word oldtile = 0;
12756 if(section_version < 8)
12757 if(!p_igetw(&oldtile,f))
12758 return 0;
12759
12760 if(!p_getc(&tempwpnspr.misc,f))
12761 {
12762 return 0;
12763 }
12764
12765 if(!p_getc(&tempwpnspr.csets,f))
12766 {
12767 return 0;
12768 }
12769
12770 if(!p_getc(&tempwpnspr.frames,f))
12771 {
12772 return 0;
12773 }
12774
12775 if(!p_getc(&tempwpnspr.speed,f))
12776 {
12777 return 0;
12778 }
12779
12780 if(!p_getc(&tempwpnspr.type,f))
12781 {
12782 return 0;
12783 }
12784
12785 if(!p_igetw(&tempwpnspr.script,f))
12786 {
12787 return 0;
12788 }
12789
12790 //2.55 starts here
12791 if ( zversion >= 0x255 )
12792 {
12793 if ( section_version >= 7 )
12794 {
12795 if(!p_igetl(&tempwpnspr.tile,f))
12796 {
12797 return 0;
12798 }
12799 }
12800 }
12801 if ( zversion < 0x255 )
12802 {
12803 tempwpnspr.tile = oldtile;
12804 }
12805 ::memcpy( &(wpnsbuf[biw[index].i]),&tempwpnspr, sizeof(wpndata));
12806 ::memcpy(weapon_string[biw[index].i], tmp_wpn_name, 64);
12807
12808 return 1;
12809 }
12810
12811 static int32_t seldata_copy;
12812 static void (*seldata_paste_func)(int32_t, int32_t);
12813
12814 void seldata_rclick_func(int32_t index, int32_t x, int32_t y)
12815 {
12816 NewMenu rcmenu {
12817 { "&Copy", [&](){seldata_copy = index;} },
12818 { "Paste", "&v", [&]()
12819 {
12820 seldata_paste_func(seldata_copy, index);
12821 saved = false;
12822 }, 0, seldata_copy < 0 },
12823 };
12824 rcmenu.pop(x, y);
12825 }
12826
12827 int32_t select_data(const char *prompt,int32_t index,const char *(proc)(int32_t,int32_t*), FONT *title_font, void (*copyFunc)(int32_t, int32_t))
12828 {
12829 if(proc==NULL)
12830 return -1;
12831
12832 list_dlg[0].dp=(void *)prompt;
12833 list_dlg[0].dp2=title_font;
12834 list_dlg[2].d1=index;
12835 ListData select_list(proc, &font);
12836 list_dlg[2].dp=(void *) &select_list;
12837
12838 large_dialog(list_dlg);
12839
12840 seldata_copy=-1;
12841 seldata_paste_func=copyFunc;
12842 if(copyFunc)
12843 {
12844 list_dlg[2].flags|=D_USER<<1;
12845 list_dlg[2].dp3=(void*)seldata_rclick_func;
12846 }
12847 else
12848 {
12849 list_dlg[2].flags&=~(D_USER<<1);
12850 list_dlg[2].dp3=0;
12851 }
12852
12853 int32_t ret=do_zqdialog(list_dlg,2);
12854
12855 if(ret==0||ret==4)
12856 {
12857 position_mouse_z(0);
12858 return -1;
12859 }
12860
12861 return list_dlg[2].d1;
12862 }
12863
12864 int32_t select_data(const char *prompt,int32_t index,const char *(proc)(int32_t,int32_t*), const char *b1, const char *b2, FONT *title_font, void (*copyFunc)(int32_t, int32_t))
12865 {
12866 if(proc==NULL)
12867 return -1;
12868
12869 list_dlg[0].dp=(void *)prompt;
12870 list_dlg[0].dp2=title_font;
12871 list_dlg[2].d1=index;
12872 ListData select_data_list(proc, &font);
12873 list_dlg[2].dp=(void *) &select_data_list;
12874 list_dlg[3].dp=(void *)b1;
12875 list_dlg[4].dp=(void *)b2;
12876
12877 large_dialog(list_dlg);
12878
12879 seldata_copy=-1;
12880 seldata_paste_func=copyFunc;
12881 if(copyFunc)
12882 {
12883 list_dlg[2].flags|=D_USER<<1;
12884 list_dlg[2].dp3=(void*)seldata_rclick_func;
12885 }
12886 else
12887 {
12888 list_dlg[2].flags&=~(D_USER<<1);
12889 list_dlg[2].dp3=0;
12890 }
12891
12892 int32_t ret = do_zqdialog(list_dlg,2);
12893 list_dlg[3].dp=(void *) "OK";
12894 list_dlg[4].dp=(void *) "Cancel";
12895
12896 if(ret==0||ret==4)
12897 {
12898 position_mouse_z(0);
12899 return -1;
12900 }
12901
12902 position_mouse_z(0);
12903 return list_dlg[2].d1;
12904 }
12905
12906 static char sfx_str_buf[42];
12907
12908 const char *sfxlist(int32_t index, int32_t *list_size)
12909 {
12910 if(index>=0)
12911 {
12912 bound(index,0,WAV_COUNT-1);
12913 sprintf(sfx_str_buf,"%d: %s",index, index ? sfx_string[index] : "(None)");
12914 return sfx_str_buf;
12915 }
12916
12917 *list_size=WAV_COUNT;
12918 return NULL;
12919 }
12920
12921 12 static ListData sfx_list(sfxlist, &font);
12922
12923 const char *screenscriptdroplist(int32_t index, int32_t *list_size)
12924 {
12925 if(index<0)
12926 {
12927 *list_size = biscreens_cnt;
12928 return NULL;
12929 }
12930
12931 return biscreens[index].first.c_str();
12932 }
12933
12934 //droplist like the dialog proc, naming scheme for this stuff is awful...
12935 12 static ListData screenscript_list(screenscriptdroplist, &a4fonts[font_pfont]);
12936
12937 int32_t onScreenScript()
12938 {
12939 call_screendata_dialog(7);
12940 return D_O_K;
12941 }
12942
12943 int32_t onScrData()
12944 {
12945 restore_mouse();
12946 call_screendata_dialog();
12947 return D_O_K;
12948 }
12949
12950 const char *roomslist(int32_t index, int32_t *list_size)
12951 {
12952 if(index>=0)
12953 {
12954 if(index>=MAXROOMTYPES)
12955 index=MAXROOMTYPES-1;
12956
12957 return roomtype_string[index];
12958 }
12959
12960 *list_size=MAXROOMTYPES;
12961 return NULL;
12962 }
12963
12964 static char number_str_buf[MIDI_TRACK_BUFFER_SIZE];
12965 int32_t number_list_size=1;
12966 bool number_list_zero=false;
12967
12968 const char *numberlist(int32_t index, int32_t *list_size)
12969 {
12970 if(index>=0)
12971 {
12972 bound(index,0,number_list_size-1);
12973 sprintf(number_str_buf,"%d",index+(number_list_zero?0:1));
12974 return number_str_buf;
12975 }
12976
12977 *list_size=number_list_size;
12978 return NULL;
12979 }
12980
12981 static char dmap_str_buf[37];
12982 int32_t dmap_list_size=MAXDMAPS;
12983 bool dmap_list_zero=true;
12984
12985 const char *dmaplist(int32_t index, int32_t *list_size)
12986 {
12987 if(index>=0)
12988 {
12989 bound(index,0,dmap_list_size-1);
12990 sprintf(dmap_str_buf,"%3d-%s",index+(dmap_list_zero?0:1), DMaps[index].name);
12991 return dmap_str_buf;
12992 }
12993
12994 *list_size=dmap_list_size;
12995 return NULL;
12996 }
12997
12998 char *hexnumlist(int32_t index, int32_t *list_size)
12999 {
13000 if(index>=0)
13001 {
13002 bound(index,0,number_list_size-1);
13003 sprintf(number_str_buf,"%X",index+(number_list_zero?0:1));
13004 return number_str_buf;
13005 }
13006
13007 *list_size=number_list_size;
13008 return NULL;
13009 }
13010
13011 const char *maplist(int32_t index, int32_t *list_size)
13012 {
13013 if(index>=0)
13014 {
13015 bound(index,0,MAXMAPS-1);
13016 sprintf(number_str_buf,"%d",index+1);
13017 return number_str_buf;
13018 }
13019
13020 *list_size=MAXMAPS;
13021 return NULL;
13022 }
13023
13024 const char *gotomaplist(int32_t index, int32_t *list_size)
13025 {
13026 if(index>=0)
13027 {
13028 bound(index,0,map_count-1);
13029 sprintf(number_str_buf,"%d",index+1);
13030 return number_str_buf;
13031 }
13032
13033 *list_size = map_count;
13034 return NULL;
13035 }
13036
13037 const char *midilist(int32_t index, int32_t *list_size)
13038 {
13039 if(index>=0)
13040
13041 {
13042 bound(index,0,MAXCUSTOMMIDIS_ZQ-1);
13043 return midi_string[index];
13044 }
13045
13046 *list_size=MAXCUSTOMMIDIS_ZQ;
13047 return NULL;
13048 }
13049
13050 const char *custommidilist(int32_t index, int32_t *list_size)
13051 {
13052 if(index>=0)
13053 {
13054 bound(index,0,MAXCUSTOMMIDIS_ZQ-1);
13055 sprintf(number_str_buf,"%3d - %s",index+(number_list_zero?0:1),customtunes[index].data?customtunes[index].title:"(Empty)");
13056 return number_str_buf;
13057 }
13058
13059 *list_size=number_list_size;
13060 return NULL;
13061 }
13062
13063 const char *enhancedmusiclist(int32_t index, int32_t *list_size)
13064 {
13065 index=index; //this is here to prevent unused parameter warnings
13066 list_size=list_size; //this is here to prevent unused parameter warnings
13067 /*if(index>=0)
13068 {
13069 bound(index,0,MAXMUSIC-1);
13070 sprintf(number_str_buf,"%3d - %s",index+(number_list_zero?0:1),enhancedMusic[index].filename[0]?enhancedMusic[index].title:"(Empty)" );
13071 return number_str_buf;
13072 }
13073 *list_size=number_list_size;*/
13074 return NULL;
13075 }
13076
13077
13078 const char *levelnumlist(int32_t index, int32_t *list_size)
13079 {
13080 if(index>=0)
13081 {
13082 bound(index,0,0xFFF);
13083 sprintf(number_str_buf,"%.3X - %s",index,palnames[index]);
13084 return number_str_buf;
13085 }
13086
13087 *list_size=MAXLEVELS;
13088 return NULL;
13089 }
13090
13091 static char shop_str_buf[40];
13092 int32_t shop_list_size=1;
13093
13094 const char *shoplist(int32_t index, int32_t *list_size)
13095 {
13096 if(index>=0)
13097 {
13098 bound(index,0,shop_list_size-1);
13099 sprintf(shop_str_buf,"%3d: %s",index,QMisc.shop[index].name);
13100 return shop_str_buf;
13101 }
13102
13103 *list_size=shop_list_size;
13104 return NULL;
13105 }
13106
13107 static char bottle_str_buf[40];
13108 int32_t bottle_list_size=1;
13109
13110 const char *bottlelist(int32_t index, int32_t *list_size)
13111 {
13112 if(index>=0)
13113 {
13114 bound(index,0,bottle_list_size-1);
13115 sprintf(bottle_str_buf,"%2d: %s",index+1,QMisc.bottle_types[index].name);
13116 return bottle_str_buf;
13117 }
13118
13119 *list_size=bottle_list_size;
13120 return NULL;
13121 }
13122
13123 static char bottleshop_str_buf[40];
13124 int32_t bottleshop_list_size=1;
13125
13126 const char *bottleshoplist(int32_t index, int32_t *list_size)
13127 {
13128 if(index>=0)
13129 {
13130 bound(index,0,bottleshop_list_size-1);
13131 sprintf(bottleshop_str_buf,"%3d: %s",index,QMisc.bottle_shop_types[index].name);
13132 return bottleshop_str_buf;
13133 }
13134
13135 *list_size=bottleshop_list_size;
13136 return NULL;
13137 }
13138
13139 static char info_str_buf[40];
13140 int32_t info_list_size=1;
13141
13142 const char *infolist(int32_t index, int32_t *list_size)
13143 {
13144 if(index>=0)
13145 {
13146 bound(index,0,info_list_size-1);
13147 sprintf(info_str_buf,"%3d: %s",index,QMisc.info[index].name);
13148 return info_str_buf;
13149 }
13150
13151 *list_size=info_list_size;
13152 return NULL;
13153 }
13154
13155 bool mapcount_will_affect_layers(word newmapcount)
13156 {
13157 for(int32_t i=0; i<(newmapcount)*MAPSCRS; i++)
13158 {
13159 mapscr *layerchecker=&TheMaps[i];
13160
13161 for(int32_t j=0; j<6; j++)
13162 {
13163 if(layerchecker->layermap[j]>(newmapcount))
13164 {
13165 return true;
13166 }
13167 }
13168 }
13169 return false;
13170 }
13171
13172 void update_map_count(word newmapcount)
13173 {
13174 if(map_count == newmapcount) return;
13175 saved = false;
13176 setMapCount2(newmapcount);
13177 //Prevent the nine 'last mapscreen' buttons from pointing to invlid locations
13178 //if the user reduces the mapcount. -Z ( 23rd September, 2019 )
13179 for ( int32_t q = 0; q < 9; q++ )
13180 {
13181 map_page[q].map = ( map_page[q].map > newmapcount-1 ) ? newmapcount-1 : map_page[q].map;
13182 }
13183 for(int32_t i=0; i<(newmapcount)*MAPSCRS; i++)
13184 {
13185 fix_layers(&TheMaps[i], false);
13186 }
13187
13188 refresh(rMAP+rSCRMAP+rMENU);
13189 }
13190
13191 int32_t onGotoMap()
13192 {
13193 int32_t ret = select_data("Goto Map",Map.getCurrMap(),gotomaplist,get_zc_font(font_lfont));
13194
13195 if(ret >= 0)
13196 {
13197 int32_t m=Map.getCurrMap();
13198 Map.setCurrMap(ret);
13199 }
13200
13201 refresh(rALL);
13202 return D_O_K;
13203 }
13204
13205 int32_t onFlags()
13206 {
13207 restore_mouse();
13208 int32_t ret=select_cflag("Select Combo Flag",Flag);
13209 position_mouse_z(0);
13210
13211 if(ret>=0)
13212 {
13213 Flag=ret;
13214 refresh(rMENU);
13215 doflags();
13216 }
13217
13218 return D_O_K;
13219 }
13220
13221 static DIALOG usedcombo_list_dlg[] =
13222 {
13223 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
13224 12 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combos Used", NULL, NULL },
13225 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13226 12 { jwin_textbox_proc, 72-12, 60+4, 176+24+1, 92+4, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
13227 12 { jwin_button_proc, 130, 163, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
13228 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
13229 };
13230
13231
13232
13233 int32_t onUsedCombos()
13234 {
13235 restore_mouse();
13236 usedcombo_list_dlg[0].dp2=get_zc_font(font_lfont);
13237
13238 int32_t usedcombos[7][300][2];
13239 char combolist_text[65536];
13240 char temptext[80];
13241
13242 int32_t drawmap=Map.getCurrMap();
13243 int32_t drawscr=Map.getCurrScr();
13244 int32_t counter[7];
13245
13246 for(int32_t layer=0; layer<7; ++layer)
13247 {
13248 counter[layer]=0;
13249
13250 if(layer==0)
13251 {
13252 drawmap=Map.getCurrMap();
13253 drawscr=Map.getCurrScr();
13254 }
13255 else
13256 {
13257 drawmap=Map.CurrScr()->layermap[layer-1]-1;
13258 drawscr=Map.CurrScr()->layerscreen[layer-1];
13259 }
13260 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
13261 if(!draw_mapscr) continue;
13262
13263 usedcombos[layer][0][0]=draw_mapscr->data[0];
13264 usedcombos[layer][0][1]=1;
13265 counter[layer]=1;
13266
13267 for(int32_t i=1; i<176; ++i)
13268 {
13269 bool used=false;
13270
13271 for(int32_t j=0; j<counter[layer]; ++j)
13272 {
13273 if(usedcombos[layer][j][0]==draw_mapscr->data[i])
13274 {
13275 ++usedcombos[layer][j][1];
13276 used=true;
13277 break;
13278 }
13279 }
13280
13281 if(!used)
13282 {
13283 usedcombos[layer][counter[layer]][0]=draw_mapscr->data[i];
13284 usedcombos[layer][counter[layer]][1]=1;
13285 ++counter[layer];
13286 }
13287 }
13288
13289 for(int32_t i=0; i<counter[layer]-1; i++)
13290 {
13291 for(int32_t j=i+1; j<counter[layer]; j++)
13292 {
13293 if(usedcombos[layer][i][0]>usedcombos[layer][j][0])
13294 {
13295 zc_swap(usedcombos[layer][i][0],usedcombos[layer][j][0]);
13296 zc_swap(usedcombos[layer][i][1],usedcombos[layer][j][1]);
13297 }
13298 }
13299 }
13300 }
13301
13302 sprintf(combolist_text, " ");
13303
13304 for(int32_t layer=0; layer<7; ++layer)
13305 {
13306 if(counter[layer]>0)
13307 {
13308 if(layer>0)
13309 {
13310 strcat(combolist_text, "\n");
13311 }
13312
13313 sprintf(temptext, "Combos on layer %d\n-----------------\n", layer);
13314 strcat(combolist_text, temptext);
13315
13316 for(int32_t i=0; i<counter[layer]; i++)
13317 {
13318 if((i<counter[layer]-1) && (((usedcombos[layer][i][1]==usedcombos[layer][i+1][1]&&(usedcombos[layer][i][0]+1==usedcombos[layer][i+1][0])) && ((i==0) || ((usedcombos[layer][i][1]!=usedcombos[layer][i-1][1])||((usedcombos[layer][i][0]-1!=usedcombos[layer][i-1][0])))))))
13319 {
13320 sprintf(temptext, "%5d ", usedcombos[layer][i][0]);
13321 strcat(combolist_text, temptext);
13322 }
13323 else if(((i>0) && (((usedcombos[layer][i][1]==usedcombos[layer][i-1][1])&&((usedcombos[layer][i][0]-1==usedcombos[layer][i-1][0]))) && ((i==counter[layer]-1) || ((usedcombos[layer][i][1]!=usedcombos[layer][i+1][1])||((usedcombos[layer][i][0]+1!=usedcombos[layer][i+1][0])))))))
13324 {
13325 sprintf(temptext, "- %5d (%3d)\n", usedcombos[layer][i][0],usedcombos[layer][i][1]);
13326 strcat(combolist_text, temptext);
13327 }
13328 else if(((i==0) && ((usedcombos[layer][i][1]!=usedcombos[layer][i+1][1])||((usedcombos[layer][i][0]+1!=usedcombos[layer][i+1][0]))))||
13329 ((i==counter[layer]-1) && ((usedcombos[layer][i][1]!=usedcombos[layer][i-1][1])||((usedcombos[layer][i][0]-1!=usedcombos[layer][i-1][0]))))||
13330 ((i>0) && (i<counter[layer]-1) && ((usedcombos[layer][i][1]!=usedcombos[layer][i+1][1])||((usedcombos[layer][i][0]+1!=usedcombos[layer][i+1][0]))) && ((usedcombos[layer][i][1]!=usedcombos[layer][i-1][1])||((usedcombos[layer][i][0]-1!=usedcombos[layer][i-1][0])))))
13331 {
13332 sprintf(temptext, " %5d (%3d)\n", usedcombos[layer][i][0],usedcombos[layer][i][1]);
13333 strcat(combolist_text, temptext);
13334 }
13335 }
13336 }
13337 }
13338
13339 strcat(combolist_text, "\n");
13340 usedcombo_list_dlg[2].dp=combolist_text;
13341 usedcombo_list_dlg[2].d2=0;
13342
13343 large_dialog(usedcombo_list_dlg);
13344
13345 do_zqdialog(usedcombo_list_dlg,2);
13346 position_mouse_z(0);
13347 return D_O_K;
13348 }
13349
13350 int32_t onItem()
13351 {
13352 restore_mouse();
13353 int32_t exit_status;
13354 int32_t current_item=Map.CurrScr()->hasitem != 0 ? Map.CurrScr()->item : -1;
13355
13356 ItemListerDialog(current_item,true).show();
13357 if(current_item != lister_sel_val)
13358 {
13359 if(lister_sel_val>=0)
13360 {
13361 saved = false;
13362 Map.CurrScr()->item = lister_sel_val;
13363 Map.CurrScr()->hasitem = true;
13364 }
13365 else
13366 {
13367 saved = false;
13368 Map.CurrScr()->hasitem = false;
13369 }
13370 }
13371
13372 refresh(rMAP+rMENU);
13373 return D_O_K;
13374 }
13375
13376 void call_room_dlg(mapscr* scr);
13377 int32_t onRoom()
13378 {
13379 restore_mouse();
13380 auto* scr = Map.CurrScr();
13381 call_room_dlg(scr);
13382
13383 refresh(rMAP+rMENU);
13384 return D_O_K;
13385 }
13386
13387 int32_t onEndString()
13388 {
13389 int32_t ret=select_data("Select Ending String",QMisc.endstring,msgslist,get_zc_font(font_lfont));
13390
13391 if(ret>=0)
13392 {
13393 saved=false;
13394 QMisc.endstring=msglistcache[ret];
13395 }
13396
13397 refresh(rMENU);
13398 return D_O_K;
13399 }
13400
13401 12 static ListData levelnum_list(levelnumlist, &font);
13402
13403 static DIALOG screen_pal_dlg[] =
13404 {
13405 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
13406 12 { jwin_win_proc, 60-12, 40, 200-16, 96, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select Palette", NULL, NULL },
13407 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13408 12 { jwin_droplist_proc, 72-12, 84+4, 161, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &levelnum_list, NULL, NULL },
13409 12 { jwin_button_proc, 70, 111, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
13410 12 { jwin_button_proc, 150, 111, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
13411 12 { jwin_text_proc, 72-12, 60+4, 168, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Note: This does not affect how the", NULL, NULL },
13412 12 { jwin_text_proc, 72-12, 72+4, 168, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "room will be displayed in-game!", NULL, NULL },
13413 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
13414 };
13415 // return list_dlg[2].d1;
13416
13417 int32_t onScreenPalette()
13418 {
13419 restore_mouse();
13420 screen_pal_dlg[0].dp2=get_zc_font(font_lfont);
13421 auto oldcol = screen_pal_dlg[2].d1 = Map.getcolor();
13422
13423 large_dialog(screen_pal_dlg);
13424 auto old_valid = Map.CurrScr()->valid;
13425 pause_dlg_tint(true);
13426 zq_set_screen_never_freeze(true);
13427 while(true)
13428 {
13429 auto ret = do_zqdialog(screen_pal_dlg,2);
13430 if(ret == 2)
13431 {
13432 Map.setcolor(screen_pal_dlg[2].d1);
13433 refresh(rALL);
13434 }
13435 else
13436 {
13437 if(ret == 3)
13438 {
13439 if(screen_pal_dlg[2].d1 != oldcol)
13440 saved=false;
13441 Map.setcolor(screen_pal_dlg[2].d1);
13442 }
13443 else
13444 {
13445 Map.setcolor(oldcol);
13446 Map.CurrScr()->valid = old_valid;
13447 }
13448 refresh(rALL);
13449 break;
13450 }
13451 }
13452 pause_dlg_tint(false);
13453 zq_set_screen_never_freeze(false);
13454
13455 rebuild_trans_table();
13456
13457 return D_O_K;
13458 }
13459
13460 int32_t onDecScrPal()
13461 {
13462 if(DisableLPalShortcuts)
13463 {
13464 lpal_dsa();
13465 return D_O_K;
13466 }
13467 restore_mouse();
13468 int32_t c=Map.getcolor();
13469 c+=511;
13470 c=c%512;
13471 Map.setcolor(c);
13472 refresh(rALL);
13473 saved = false;
13474 return D_O_K;
13475 }
13476
13477 int32_t onIncScrPal()
13478 {
13479 if(DisableLPalShortcuts)
13480 {
13481 lpal_dsa();
13482 return D_O_K;
13483 }
13484 restore_mouse();
13485 int32_t c=Map.getcolor();
13486 c+=1;
13487 c=c%512;
13488 Map.setcolor(c);
13489 refresh(rALL);
13490 saved = false;
13491 return D_O_K;
13492 }
13493
13494 int32_t PalWrap(int32_t kX, int32_t const kLowerBound, int32_t const kUpperBound)
13495 {
13496 int32_t range_size = kUpperBound - kLowerBound + 1;
13497
13498 if (kX < kLowerBound)
13499 kX += range_size * ((kLowerBound - kX) / range_size + 1);
13500
13501 return kLowerBound + (kX - kLowerBound) % range_size;
13502 }
13503
13504 int32_t onDecScrPal16()
13505 {
13506 if(DisableLPalShortcuts)
13507 {
13508 lpal_dsa();
13509 return D_O_K;
13510 }
13511 restore_mouse();
13512 int32_t c=Map.getcolor();
13513
13514 c = PalWrap( ( c-0x10 ), 0, 511 );
13515
13516 Map.setcolor(c);
13517 refresh(rALL);
13518 saved = false;
13519 return D_O_K;
13520 }
13521
13522 int32_t onIncScrPal16()
13523 {
13524 if(DisableLPalShortcuts)
13525 {
13526 lpal_dsa();
13527 return D_O_K;
13528 }
13529 restore_mouse();
13530 int32_t c=Map.getcolor();
13531
13532 c = PalWrap( ( c+0x10 ), 0, 511 );
13533 Map.setcolor(c);
13534 refresh(rALL);
13535 saved = false;
13536 return D_O_K;
13537 }
13538
13539 int32_t onZoomIn()
13540 {
13541 change_mapscr_zoom(-1);
13542 return D_O_K;
13543 }
13544
13545 int32_t onZoomOut()
13546 {
13547 change_mapscr_zoom(1);
13548 return D_O_K;
13549 }
13550
13551 int32_t d_ndroplist_proc(int32_t msg,DIALOG *d,int32_t c)
13552 {
13553 int32_t ret = jwin_droplist_proc(msg,d,c);
13554
13555 // The only place this proc is used is in the info type editor.
13556 // If it's ever used anywhere else, this will probably need to be changed.
13557 // Maybe add a flag for it or something.
13558 int32_t msgID=msg_at_pos(d->d1);
13559
13560 switch(msg)
13561 {
13562 case MSG_DRAW:
13563 case MSG_CHAR:
13564 case MSG_CLICK:
13565 textprintf_ex(screen,font,d->x - 48,d->y + 4,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%5d",msgID);
13566 }
13567
13568 return ret;
13569 }
13570
13571 int32_t d_idroplist_proc(int32_t msg,DIALOG *d,int32_t c)
13572 {
13573 int32_t ret = jwin_droplist_proc(msg,d,c);
13574
13575 switch(msg)
13576 {
13577 case MSG_DRAW:
13578 case MSG_CHAR:
13579 case MSG_CLICK:
13580 int32_t tile = bii[d->d1].i >=0 ? itemsbuf[bii[d->d1].i].tile : 0;
13581 int32_t cset = bii[d->d1].i >=0 ? itemsbuf[bii[d->d1].i].csets&15 : 0;
13582 int32_t x = d->x + d->w + 4;
13583 int32_t y = d->y - 8;
13584 int32_t w = 32;
13585 int32_t h = 32;
13586
13587 BITMAP *buf = create_bitmap_ex(8,16,16);
13588 BITMAP *bigbmp = create_bitmap_ex(8,w,h);
13589
13590 if(buf && bigbmp)
13591 {
13592 clear_bitmap(buf);
13593
13594 if(tile)
13595 overtile16(buf, tile,0,0,cset,0);
13596
13597 stretch_blit(buf, bigbmp, 0,0, 16, 16, 0, 0, w, h);
13598 destroy_bitmap(buf);
13599 jwin_draw_frame(screen,x,y,w+4,h+4,FR_DEEP);
13600 blit(bigbmp,screen,0,0,x+2,y+2,w,h);
13601 destroy_bitmap(bigbmp);
13602 }
13603
13604 }
13605
13606 return ret;
13607 }
13608
13609 int32_t d_nidroplist_proc(int32_t msg,DIALOG *d,int32_t c)
13610 {
13611 int32_t ret = d_idroplist_proc(msg,d,c);
13612
13613 switch(msg)
13614 {
13615 case MSG_DRAW:
13616 case MSG_CHAR:
13617 case MSG_CLICK:
13618 textprintf_ex(screen,font,d->x - 48,d->y + 4,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%5d",bii[d->d1].i);
13619 }
13620
13621 return ret;
13622 }
13623
13624 // Triforce pieces
13625 static byte triframe_points[9*4] =
13626 {
13627 0,2,2,0, 2,0,4,2, 0,2,4,2, 1,1,3,1, 2,0,2,2,
13628 1,1,1,2, 1,1,2,2, 3,1,3,2, 3,1,2,2
13629 };
13630
13631 int32_t d_tri_frame_proc(int32_t msg,DIALOG *d,int32_t c)
13632 {
13633 //these are here to bypass compiler warnings about unused arguments
13634 c=c;
13635
13636 if(msg==MSG_DRAW)
13637 {
13638 int32_t x[5],y[3];
13639
13640 x[0]=d->x;
13641 x[1]=d->x+(d->w>>2);
13642 x[2]=d->x+(d->w>>1);
13643 x[3]=d->x+(d->w>>1)+(d->w>>2);
13644 x[4]=d->x+d->w;
13645 y[0]=d->y;
13646 y[1]=d->y+(d->h>>1);
13647 y[2]=d->y+d->h;
13648
13649 byte *p = triframe_points;
13650
13651 for(int32_t i=0; i<9; i++)
13652 {
13653 line(screen,x[*p],y[*(p+1)],x[*(p+2)],y[*(p+3)],d->fg);
13654 p+=4;
13655 }
13656 }
13657
13658 return D_O_K;
13659 }
13660
13661 int32_t d_tri_edit_proc(int32_t msg,DIALOG *d,int32_t c)
13662 {
13663 jwin_button_proc(msg,d,c);
13664
13665 if(msg==MSG_CLICK)
13666 {
13667 int32_t v = getnumber("Piece Number",d->d1);
13668
13669 if(v>=0)
13670 {
13671 bound(v,1,8);
13672
13673 if(v!=d->d1)
13674 {
13675 DIALOG *tp = d - d->d2;
13676
13677 for(int32_t i=0; i<8; i++)
13678 {
13679 if(tp->d1==v)
13680 {
13681 tp->d1 = d->d1;
13682 ((char*)(tp->dp))[0] = d->d1+'0';
13683 jwin_button_proc(MSG_DRAW,tp,0);
13684 }
13685
13686 ++tp;
13687 }
13688
13689 d->d1 = v;
13690 ((char*)(d->dp))[0] = v+'0';
13691 }
13692 }
13693
13694 d->flags = 0;
13695 jwin_button_proc(MSG_DRAW,d,0);
13696 }
13697
13698 return D_O_K;
13699 }
13700
13701 static DIALOG tp_dlg[] =
13702 {
13703 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
13704 12 { jwin_win_proc, 56, 32, 208, 160, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
13705 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13706 12 { d_tri_frame_proc, 64, 56, 192, 96, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, NULL, NULL, NULL },
13707 // 3
13708 12 { d_tri_edit_proc, 138, 82, 17, 17, vc(14), vc(1), 0, 0, 0, 0, (void *) "1", NULL, NULL },
13709 12 { d_tri_edit_proc, 166, 82, 17, 17, vc(14), vc(1), 0, 0, 0, 1, (void *) "2", NULL, NULL },
13710 12 { d_tri_edit_proc, 90, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 2, (void *) "3", NULL, NULL },
13711 12 { d_tri_edit_proc, 214, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 3, (void *) "4", NULL, NULL },
13712 // 7
13713 12 { d_tri_edit_proc, 138, 110, 17, 17, vc(14), vc(1), 0, 0, 0, 4, (void *) "5", NULL, NULL },
13714 12 { d_tri_edit_proc, 118, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 5, (void *) "6", NULL, NULL },
13715 12 { d_tri_edit_proc, 166, 110, 17, 17, vc(14), vc(1), 0, 0, 0, 6, (void *) "7", NULL, NULL },
13716 12 { d_tri_edit_proc, 186, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 7, (void *) "8", NULL, NULL },
13717 // 11
13718 12 { jwin_button_proc, 90, 166, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
13719 12 { jwin_button_proc, 170, 166, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
13720 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
13721 };
13722
13723 int32_t onTriPieces()
13724 {
13725 tp_dlg[0].dp2=get_zc_font(font_lfont);
13726 char temptext[8][2];
13727
13728 for(int32_t i=0; i<8; i++)
13729 {
13730 tp_dlg[i+3].d1 = QMisc.triforce[i];
13731 // ((char*)(tp_dlg[i+3].dp))[0] = QMisc.triforce[i]+'0';
13732 sprintf(temptext[i], "%d", QMisc.triforce[i]);
13733 tp_dlg[i+3].dp=temptext[i];
13734 }
13735
13736 large_dialog(tp_dlg);
13737
13738 if(do_zqdialog(tp_dlg,-1) == 11)
13739 {
13740 saved=false;
13741
13742 for(int32_t i=0; i<8; i++)
13743 QMisc.triforce[i] = tp_dlg[i+3].d1;
13744 }
13745
13746 return D_O_K;
13747 }
13748
13749 int32_t d_maptile_proc(int32_t msg,DIALOG *d,int32_t c);
13750 bool small_dmap=false;
13751
13752 static DIALOG dmapmaps_dlg[] =
13753 {
13754
13755 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
13756 { jwin_win_proc, 4, 18, 313, 217, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Custom DMap Map Styles", NULL, NULL },
13757 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13758 { jwin_button_proc, 93, 208, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
13759 { jwin_button_proc, 168, 208, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
13760 { d_ctext2_proc, 160, 38, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimaps", NULL, NULL },
13761 { d_ctext2_proc, 112, 46, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Without Map", NULL, NULL },
13762 { d_ctext2_proc, 208, 46, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "With Map", NULL, NULL },
13763
13764 { d_ctext2_proc, 162, 110, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Large Maps", NULL, NULL },
13765 { d_ctext2_proc, 80, 118, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Without Map", NULL, NULL },
13766 { d_ctext2_proc, 240, 118, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "With Map", NULL, NULL },
13767 // 5
13768 { d_maptile_proc, 72, 54, 80, 48, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13769 { d_maptile_proc, 168, 54, 80, 48, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13770 { d_maptile_proc, 8, 126, 144, 80, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13771 { d_maptile_proc, 168, 126, 144, 80, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13772 // 11
13773 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
13774 };
13775
13776 int32_t d_hexedit_proc(int32_t msg,DIALOG *d,int32_t c)
13777 {
13778 return jwin_hexedit_proc(msg,d,c);
13779 }
13780
13781 void drawgrid(BITMAP *dest,int32_t x,int32_t y,int32_t grid,int32_t fg,int32_t bg,int32_t div)
13782 {
13783 if(div!=-1)
13784 rectfill(dest,x-1,y-1,x+63,y+3,div);
13785
13786 for(int32_t dx=0; dx<64; dx+=8)
13787 {
13788 if(grid&0x80)
13789 rectfill(dest,x+dx,y,x+dx+6,y+2,fg);
13790 else if(bg!=-1)
13791 rectfill(dest,x+dx,y,x+dx+6,y+2,bg);
13792
13793 grid<<=1;
13794 }
13795 }
13796
13797 void drawovergrid(BITMAP *dest,int32_t x,int32_t y,int32_t grid,int32_t color,int32_t div)
13798 {
13799 if(div!=-1)
13800 rectfill(dest,x-1,y-1,x+63,y+3,div);
13801
13802 for(int32_t dx=0; dx<64; dx+=4)
13803 {
13804 rectfill(dest,x+dx,y,x+dx+2,y+2,color);
13805 grid<<=1;
13806 }
13807 }
13808
13809 void drawgrid(BITMAP *dest,int32_t x,int32_t y,int32_t w, int32_t h, int32_t tw, int32_t th, int32_t *grid,int32_t fg,int32_t bg,int32_t div)
13810 {
13811 //these are here to bypass compiler warnings about unused arguments
13812 w=w;
13813 tw=tw;
13814 th=th;
13815
13816 rectfill(dest,x,y,x+(8*8),y+(1*4),div);
13817
13818 for(int32_t dy=0; dy<h; dy++)
13819 {
13820 for(int32_t dx=0; dx<64; dx+=8)
13821 {
13822 if(grid[0]&0x80)
13823 rectfill(dest,x+dx,y,x+dx+6,y+2,fg);
13824 else
13825 rectfill(dest,x+dx,y,x+dx+6,y+2,bg);
13826
13827 grid[0]<<=1;
13828 }
13829 }
13830 }
13831
13832 void drawgrid_s(BITMAP *dest,int32_t x,int32_t y,int32_t grid,int32_t fg,int32_t bg,int32_t div)
13833 {
13834 rectfill(dest,x-1,y-1,x+63,y+3,div);
13835
13836 for(int32_t dx=0; dx<64; dx+=8)
13837 {
13838 rectfill(dest,x+dx,y,x+dx+6,y+2,bg);
13839
13840 if(grid&0x80)
13841 rectfill(dest,x+dx+2,y,x+dx+4,y+2,fg);
13842
13843 grid<<=1;
13844 }
13845 }
13846
13847 void drawdmap(int32_t dmap)
13848 {
13849 int32_t c;
13850 zcolors mc=QMisc.colors;
13851
13852 switch((DMaps[dmap].type&dmfTYPE))
13853 {
13854 case dmDNGN:
13855 case dmCAVE:
13856 clear_bitmap(dmapbmp_small);
13857
13858 if(DMaps[dmap].minimap_tile[1])
13859 ;
13860 // overworld_map_tile overrides the NES minimap. dungeon_map_tile does not.
13861 else for(int32_t y=1; y<33; y+=4)
13862 drawgrid(dmapbmp_small,0,y,DMaps[dmap].grid[y>>2], DMaps[dmap].flags&dmfMINIMAPCOLORFIX ? mc.cave_fg : mc.dngn_fg, -1, -1);
13863
13864 c=DMaps[dmap].compass;
13865 // rectfill(dmapbmp,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,dvc(2*4));
13866 rectfill(dmapbmp_small,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,vc(4));
13867 c=DMaps[dmap].cont;
13868 rectfill(dmapbmp_small,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,vc(10));
13869 break;
13870
13871 case dmOVERW:
13872 clear_bitmap(dmapbmp_small);
13873
13874 if(DMaps[dmap].minimap_tile[1])
13875 ;
13876 else if(!mc.overworld_map_tile)
13877 for(int32_t y=1; y<33; y+=4)
13878 drawovergrid(dmapbmp_small,1,y,DMaps[dmap].grid[y>>2],mc.overw_bg,vc(0));
13879
13880 c=DMaps[dmap].cont;
13881 rectfill(dmapbmp_small,(c&15)*4+1,(c>>4)*4+1,(c&15)*4+3,(c>>4)*4+3,vc(10));
13882 break;
13883
13884 case dmBSOVERW:
13885 clear_bitmap(dmapbmp_small);
13886
13887 if(DMaps[dmap].minimap_tile[1])
13888 ;
13889 else if(!mc.overworld_map_tile)
13890 for(int32_t y=1; y<33; y+=4)
13891 // drawgrid_s(dmapbmp,1,y,DMaps[dmap].grid[y>>2],dvc(2*4),dvc(2*3),dvc(3+4));
13892 drawgrid_s(dmapbmp_small,0,y,DMaps[dmap].grid[y>>2],mc.bs_goal,mc.bs_dk,vc(14));
13893
13894 c=DMaps[dmap].cont;
13895 rectfill(dmapbmp_small,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,vc(10));
13896 break;
13897 }
13898 }
13899
13900 void drawdmap_screen(int32_t x, int32_t y, int32_t w, int32_t h, int32_t dmap)
13901 {
13902 BITMAP *tempbmp = create_bitmap_ex(8,w,h);
13903 clear_to_color(tempbmp, vc(0));
13904 zcolors mc=QMisc.colors;
13905
13906 // rectfill(tempbmp,x,y,x+w-1,y+h-1,vc(0));
13907
13908 if(DMaps[dmap].minimap_tile[1])
13909 {
13910 draw_block(tempbmp,0,0,DMaps[dmap].minimap_tile[1],DMaps[dmap].minimap_cset[1],5,3);
13911 }
13912 else if(((DMaps[dmap].type&dmfTYPE)==dmDNGN || (DMaps[dmap].type&dmfTYPE)==dmCAVE) && mc.dungeon_map_tile)
13913 {
13914 draw_block(tempbmp,0,0,mc.dungeon_map_tile,mc.dungeon_map_cset,5,3);
13915 }
13916 else if(((DMaps[dmap].type&dmfTYPE)==dmOVERW || (DMaps[dmap].type&dmfTYPE)==dmBSOVERW) && mc.overworld_map_tile)
13917 {
13918 draw_block(tempbmp,0,0,mc.overworld_map_tile,mc.overworld_map_cset,5,3);
13919 }
13920
13921 masked_blit(dmapbmp_small,tempbmp,0,0,8,7,65,33);
13922
13923 blit(tempbmp,screen,0,0,x,y,w,h);
13924 destroy_bitmap(tempbmp);
13925
13926 }
13927
13928 int32_t d_dmaplist_proc(int32_t msg,DIALOG *d,int32_t c)
13929 {
13930 if(msg==MSG_DRAW)
13931 {
13932 int32_t dmap = d->d1;
13933 int32_t xy[6] = {44,92,128,100,128,110};
13934 //int32_t *xy = (int32_t*)(d->dp3);
13935 float temp_scale = 1.5;
13936
13937 drawdmap(dmap);
13938
13939 if(xy[0]>-1000&&xy[1]>-1000)
13940 {
13941 int32_t x = d->x+int32_t((xy[0]-2)*temp_scale);
13942 int32_t y = d->y+int32_t((xy[1]-2)*temp_scale);
13943 int32_t w = 84;
13944 int32_t h = 52;
13945 jwin_draw_frame(screen,x,y,w,h,FR_DEEP);
13946 drawdmap_screen(x+2,y+2,w-4,h-4,dmap);
13947 }
13948
13949 if(xy[2]>-1000&&xy[3]>-1000)
13950 {
13951 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[2])*temp_scale),d->y+int32_t((xy[3])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Map: %-3d",DMaps[d->d1].map+1);
13952 }
13953
13954 if(xy[4]>-1000&&xy[5]>-1000)
13955 {
13956 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[4])*temp_scale),d->y+int32_t((xy[5])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Level: %-3d",DMaps[d->d1].level);
13957 }
13958 }
13959
13960 return jwin_list_proc(msg,d,c);
13961 }
13962
13963 int32_t d_dropdmaplist_proc(int32_t msg,DIALOG *d,int32_t c)
13964 {
13965 if(msg==MSG_DRAW)
13966 {
13967 int32_t dmap = d->d1;
13968 int32_t *xy = (int32_t*)(d->dp3);
13969 float temp_scale = 1.5;
13970
13971 drawdmap(dmap);
13972
13973 if(xy[0]>-1000&&xy[1]>-1000)
13974 {
13975 int32_t x = d->x+int32_t((xy[0]-2)*temp_scale);
13976 int32_t y = d->y+int32_t((xy[1]-2)*temp_scale);
13977 int32_t w = 84;
13978 int32_t h = 52;
13979 jwin_draw_frame(screen,x,y,w,h,FR_DEEP);
13980 drawdmap_screen(x+2,y+2,w-4,h-4,dmap);
13981 }
13982
13983 if(xy[2]>-1000&&xy[3]>-1000)
13984 {
13985 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[2])*temp_scale),d->y+int32_t((xy[3])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Map: %-3d",DMaps[d->d1].map+1);
13986 }
13987
13988 if(xy[4]>-1000&&xy[5]>-1000)
13989 {
13990 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[4])*temp_scale),d->y+int32_t((xy[5])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Level: %-3d",DMaps[d->d1].level);
13991 }
13992 }
13993
13994 return jwin_droplist_proc(msg,d,c);
13995 }
13996
13997 void drawxmap(ALLEGRO_BITMAP* dest, int32_t themap, int32_t xoff, bool large, int dx, int dy)
13998 {
13999 ALLEGRO_STATE old_state;
14000 al_store_state(&old_state, ALLEGRO_STATE_TARGET_BITMAP);
14001
14002 al_set_target_bitmap(dest);
14003 al_clear_to_color(al_map_rgba(0, 0, 0, 0));
14004
14005 int32_t cols = (large ? 8 : 16);
14006 int32_t col_width = large ? 22 : 11;
14007 int32_t dot_width = (large ? 6 : 4);
14008 int32_t dot_offset = (large ? 7 : 3);
14009 int32_t l = 10;
14010
14011 for (int32_t y = 0; y < 8; y++)
14012 {
14013 // Users might have set the dmap to a map that has since been deleted.
14014 if (themap >= Map.getMapCount())
14015 break;
14016
14017 for (int32_t x = 0; x < cols; x++)
14018 {
14019 if (x + xoff < 0 || x + xoff > 15)
14020 continue;
14021
14022 const mapscr* scr = get_canonical_scr(themap, y * 16 + x + (large ? xoff : 0));
14023 if (!(scr->valid & mVALID))
14024 continue;
14025
14026 al_draw_filled_rectangle(dx + (x * col_width), dy + (y * l), dx + (x * col_width + col_width), dy + ((y * l) + l), real_lc1(scr->color));
14027 al_draw_filled_rectangle(dx + (x * col_width + dot_offset), dy + (y * l + 3), dx + (x * col_width + dot_offset + dot_width), dy + (y * l + l - 3), real_lc2(scr->color));
14028 }
14029 }
14030
14031 al_restore_state(&old_state);
14032 }
14033
14034 const char *dmapscriptdroplist(int32_t index, int32_t *list_size)
14035 {
14036 if(index<0)
14037 {
14038 *list_size = bidmaps_cnt;
14039 return NULL;
14040 }
14041
14042 return bidmaps[index].first.c_str();
14043 }
14044
14045 12 static ListData dmapscript_list(dmapscriptdroplist, &a4fonts[font_pfont]);
14046
14047 //int32_t selectdmapxy[6] = {90,142,164,150,164,160};
14048 int32_t selectdmapxy[6] = {44,92,128,100,128,110};
14049
14050 12 static ListData dmap_list(dmaplist, &font);
14051
14052 12 static dmap copiedDMap;
14053 static byte dmapcopied = 0;
14054
14055 int32_t writesomedmaps(PACKFILE *f, int32_t first, int32_t last, int32_t max)
14056 {
14057
14058 dword section_version=V_DMAPS;
14059 int32_t zversion = ZELDA_VERSION;
14060 int32_t zbuild = VERSION_BUILD;
14061
14062 if(!p_iputl(V_ZDMAP,f))
14063 {
14064 return 0;
14065 }
14066
14067 //section version info
14068 if(!p_iputl(zversion,f))
14069 {
14070 return 0;
14071 }
14072 if(!p_iputl(zbuild,f))
14073 {
14074 return 0;
14075 }
14076 if(!p_iputw(section_version,f))
14077 {
14078 new_return(2);
14079 }
14080
14081 if(!write_deprecated_section_cversion(section_version, f))
14082 {
14083 new_return(3);
14084 }
14085 //max possible at this time
14086 if(!p_iputl(max,f))
14087 {
14088 new_return(4);
14089 }
14090 //first id written
14091 if(!p_iputl(first,f))
14092 {
14093 new_return(5);
14094 }
14095 //last id written
14096 if(!p_iputl(last,f))
14097 {
14098 new_return(6);
14099 }
14100 int32_t count = last-first;
14101 //number written
14102 if(!p_iputl(count,f))
14103 {
14104 new_return(7);
14105 }
14106
14107
14108 for ( int32_t i = first; i <= last; ++i )
14109 {
14110 if ( i > max ) break;
14111
14112 if(!p_putc(DMaps[i].map,f))
14113 {
14114 new_return(8);
14115 }
14116
14117 if(!p_iputw(DMaps[i].level,f))
14118 {
14119 new_return(9);
14120 }
14121
14122 if(!p_putc(DMaps[i].xoff,f))
14123 {
14124 new_return(10);
14125 }
14126
14127 if(!p_putc(DMaps[i].compass,f))
14128 {
14129 new_return(11);
14130 }
14131
14132 if(!p_iputw(DMaps[i].color,f))
14133 {
14134 new_return(12);
14135 }
14136
14137 if(!p_putc(DMaps[i].midi,f))
14138 {
14139 new_return(13);
14140 }
14141
14142 if(!p_putc(DMaps[i].cont,f))
14143 {
14144 new_return(14);
14145 }
14146
14147 if(!p_putc(DMaps[i].type,f))
14148 {
14149 new_return(15);
14150 }
14151
14152 for(int32_t j=0; j<8; j++)
14153 {
14154 if(!p_putc(DMaps[i].grid[j],f))
14155 {
14156 new_return(16);
14157 }
14158 }
14159
14160 //16
14161 if(!pfwrite(&DMaps[i].name,sizeof(DMaps[0].name),f))
14162 {
14163 new_return(17);
14164 }
14165
14166 if(!p_putwstr(DMaps[i].title,f))
14167 {
14168 new_return(18);
14169 }
14170
14171 if(!pfwrite(&DMaps[i].intro,sizeof(DMaps[0].intro),f))
14172 {
14173 new_return(19);
14174 }
14175
14176 if(!p_iputl(DMaps[i].minimap_tile[0],f))
14177 {
14178 new_return(20);
14179 }
14180
14181 if(!p_putc(DMaps[i].minimap_cset[0],f))
14182 {
14183 new_return(21);
14184 }
14185
14186 if(!p_iputl(DMaps[i].minimap_tile[1],f))
14187 {
14188 new_return(22);
14189 }
14190
14191 if(!p_putc(DMaps[i].minimap_cset[1],f))
14192 {
14193 new_return(23);
14194 }
14195
14196 if(!p_iputl(DMaps[i].largemap_tile[0],f))
14197 {
14198 new_return(24);
14199 }
14200
14201 if(!p_putc(DMaps[i].largemap_cset[0],f))
14202 {
14203 new_return(25);
14204 }
14205
14206 if(!p_iputl(DMaps[i].largemap_tile[1],f))
14207 {
14208 new_return(26);
14209 }
14210
14211 if(!p_putc(DMaps[i].largemap_cset[1],f))
14212 {
14213 new_return(27);
14214 }
14215
14216 if(!pfwrite(&DMaps[i].tmusic,sizeof(DMaps[0].tmusic),f))
14217 {
14218 new_return(28);
14219 }
14220
14221 if(!p_putc(DMaps[i].tmusictrack,f))
14222 {
14223 new_return(29);
14224 }
14225
14226 if(!p_putc(DMaps[i].active_subscreen,f))
14227 {
14228 new_return(30);
14229 }
14230
14231 if(!p_putc(DMaps[i].passive_subscreen,f))
14232 {
14233 new_return(31);
14234 }
14235
14236 byte disabled[32];
14237 memset(disabled,0,32);
14238
14239 for(int32_t j=0; j<MAXITEMS; j++)
14240 {
14241 if(DMaps[i].disableditems[j])
14242 {
14243 disabled[j/8] |= (1 << (j%8));
14244 }
14245 }
14246
14247 if(!pfwrite(disabled,32,f))
14248 {
14249 new_return(32);
14250 }
14251
14252 if(!p_iputl(DMaps[i].flags,f))
14253 {
14254 new_return(33);
14255 }
14256 if(!p_putc(DMaps[i].sideview,f))
14257 {
14258 new_return(30);
14259 }
14260 if(!p_iputw(DMaps[i].script,f))
14261 {
14262 new_return(31);
14263 }
14264 for ( int32_t q = 0; q < 8; q++ )
14265 {
14266 if(!p_iputl(DMaps[i].initD[q],f))
14267 {
14268 new_return(32);
14269 }
14270
14271 }
14272 for ( int32_t q = 0; q < 8; q++ )
14273 {
14274 for ( int32_t w = 0; w < 65; w++ )
14275 {
14276 if (!p_putc(DMaps[i].initD_label[q][w],f))
14277 {
14278 new_return(33);
14279 }
14280 }
14281 }
14282 if(!p_iputw(DMaps[i].active_sub_script,f))
14283 {
14284 new_return(34);
14285 }
14286 if(!p_iputw(DMaps[i].passive_sub_script,f))
14287 {
14288 new_return(35);
14289 }
14290 for(int32_t q = 0; q < 8; ++q)
14291 {
14292 if(!p_iputl(DMaps[i].sub_initD[q],f))
14293 {
14294 new_return(36);
14295 }
14296 }
14297 for(int32_t q = 0; q < 8; ++q)
14298 {
14299 for(int32_t w = 0; w < 65; ++w)
14300 {
14301 if(!p_putc(DMaps[i].sub_initD_label[q][w],f))
14302 {
14303 new_return(37);
14304 }
14305 }
14306 }
14307 if(!p_iputw(DMaps[i].onmap_script,f))
14308 {
14309 new_return(35);
14310 }
14311 for(int32_t q = 0; q < 8; ++q)
14312 {
14313 if(!p_iputl(DMaps[i].onmap_initD[q],f))
14314 {
14315 new_return(36);
14316 }
14317 }
14318 for(int32_t q = 0; q < 8; ++q)
14319 {
14320 for(int32_t w = 0; w < 65; ++w)
14321 {
14322 if(!p_putc(DMaps[i].onmap_initD_label[q][w],f))
14323 {
14324 new_return(37);
14325 }
14326 }
14327 }
14328 if (!p_iputw(DMaps[i].mirrorDMap, f))
14329 {
14330 new_return(38);
14331 }
14332 if (!p_iputl(DMaps[i].tmusic_loop_start, f))
14333 {
14334 new_return(39);
14335 }
14336 if (!p_iputl(DMaps[i].tmusic_loop_end, f))
14337 {
14338 new_return(40);
14339 }
14340 if (!p_iputl(DMaps[i].tmusic_xfade_in, f))
14341 {
14342 new_return(41);
14343 }
14344 if (!p_iputl(DMaps[i].tmusic_xfade_out, f))
14345 {
14346 new_return(42);
14347 }
14348 }
14349
14350 return 1;
14351 }
14352
14353
14354 int32_t readsomedmaps(PACKFILE *f)
14355 {
14356 dword section_version = 0;
14357 int32_t zversion = 0;
14358 int32_t zbuild = 0;
14359 dmap tempdmap{};
14360
14361 int32_t first = 0, last = 0, max = 0, count = 0;
14362 int32_t datatype_version = 0;
14363
14364 //char dmapstring[64]={0};
14365 //section version info
14366 if(!p_igetl(&datatype_version,f))
14367 {
14368 return 0;
14369 }
14370 if ( datatype_version < 0 )
14371 {
14372 if(!p_igetl(&zversion,f))
14373 {
14374 return 0;
14375 }
14376 }
14377 else
14378 {
14379 zversion = datatype_version;
14380 }
14381 if(!p_igetl(&zbuild,f))
14382 {
14383 return 0;
14384 }
14385
14386 if(!p_igetw(&section_version,f))
14387 {
14388 return 0;
14389 }
14390
14391 if(!read_deprecated_section_cversion(f))
14392 {
14393 return 0;
14394 }
14395 if ( datatype_version < 0 )
14396 {
14397 if(!p_igetl(&max,f))
14398 {
14399 return 0;
14400 }
14401 if(!p_igetl(&first,f))
14402 {
14403 return 0;
14404 }
14405 if(!p_igetl(&last,f))
14406 {
14407 return 0;
14408 }
14409 if(!p_igetl(&count,f))
14410 {
14411 return 0;
14412 }
14413 }
14414 else
14415 {
14416 first = 0;
14417 last = 0;
14418 count = 1;
14419 max = 255;
14420 }
14421
14422
14423
14424
14425 al_trace("readsomedmaps section_version: %d\n", section_version);
14426
14427 if ( zversion > ZELDA_VERSION )
14428 {
14429 al_trace("Cannot read .zdmap packfile made in ZC version (%x) in this version of ZC (%x)\n", zversion, ZELDA_VERSION);
14430 return 0;
14431 }
14432 else if (( section_version > V_DMAPS ))
14433 {
14434 al_trace("Cannot read .zdmap packfile made using V_DMAPS (%d)\n", section_version);
14435 return 0;
14436 }
14437 else
14438 {
14439 al_trace("Reading a .zdmap packfile made in ZC Version: %x, Build: %d\n", zversion, zbuild);
14440 }
14441 //if(!pfread(&dmapstring, 64, f))
14442 //{
14443 // return 0;
14444 //}
14445
14446
14447
14448 for ( int32_t i = first; i <= last; ++i )
14449 {
14450 if(!p_getc(&tempdmap.map,f))
14451 {
14452 return 0;
14453 }
14454
14455 if(!p_igetw(&tempdmap.level,f))
14456 {
14457 return 0;
14458 }
14459
14460 if(!p_getc(&tempdmap.xoff,f))
14461 {
14462 return 0;
14463 }
14464
14465 if(!p_getc(&tempdmap.compass,f))
14466 {
14467 return 0;
14468 }
14469
14470 if(!p_igetw(&tempdmap.color,f))
14471 {
14472 return 0;
14473 }
14474
14475 if(!p_getc(&tempdmap.midi,f))
14476 {
14477 return 0;
14478 }
14479
14480 if(!p_getc(&tempdmap.cont,f))
14481 {
14482 return 0;
14483 }
14484
14485 if(!p_getc(&tempdmap.type,f))
14486 {
14487 return 0;
14488 }
14489
14490 for(int32_t j=0; j<8; j++)
14491 {
14492 if(!p_getc(&tempdmap.grid[j],f))
14493 {
14494 return 0;
14495 }
14496 }
14497
14498 //16
14499 if(!pfread(&tempdmap.name,sizeof(DMaps[0].name),f))
14500 {
14501 return 0;
14502 }
14503
14504 if (section_version<20)
14505 {
14506 char title[22];
14507 if (!p_getstr(title, sizeof(title) - 1, f))
14508 {
14509 return 0;
14510 }
14511 tempdmap.title.assign(title);
14512 }
14513 else
14514 {
14515 if (!p_getwstr(&tempdmap.title, f))
14516 {
14517 return 0;
14518 }
14519 }
14520
14521 if(!pfread(&tempdmap.intro,sizeof(DMaps[0].intro),f))
14522 {
14523 return 0;
14524 }
14525
14526 if(!p_igetl(&tempdmap.minimap_tile[0],f))
14527 {
14528 return 0;
14529 }
14530
14531 if(!p_getc(&tempdmap.minimap_cset[0],f))
14532 {
14533 return 0;
14534 }
14535
14536 if(!p_igetl(&tempdmap.minimap_tile[1],f))
14537 {
14538 return 0;
14539 }
14540
14541 if(!p_getc(&tempdmap.minimap_cset[1],f))
14542 {
14543 return 0;
14544 }
14545
14546 if(!p_igetl(&tempdmap.largemap_tile[0],f))
14547 {
14548 return 0;
14549 }
14550
14551 if(!p_getc(&tempdmap.largemap_cset[0],f))
14552 {
14553 return 0;
14554 }
14555
14556 if(!p_igetl(&tempdmap.largemap_tile[1],f))
14557 {
14558 return 0;
14559 }
14560
14561 if(!p_getc(&tempdmap.largemap_cset[1],f))
14562 {
14563 return 0;
14564 }
14565
14566 if(!pfread(&tempdmap.tmusic,sizeof(DMaps[0].tmusic),f))
14567 {
14568 return 0;
14569 }
14570
14571 if(!p_getc(&tempdmap.tmusictrack,f))
14572 {
14573 return 0;
14574 }
14575
14576 if(!p_getc(&tempdmap.active_subscreen,f))
14577 {
14578 return 0;
14579 }
14580
14581 if(!p_getc(&tempdmap.passive_subscreen,f))
14582 {
14583 return 0;
14584 }
14585
14586 byte disabled[32];
14587 memset(disabled,0,32);
14588
14589 if(!pfread(&disabled, 32, f)) return 0;
14590
14591 for(int32_t j=0; j<MAXITEMS; j++)
14592 {
14593 if(disabled[j/8] & (1 << (j%8))) tempdmap.disableditems[j]=1;
14594 else tempdmap.disableditems[j]=0;
14595 }
14596
14597
14598 if(!p_igetl(&tempdmap.flags,f))
14599 {
14600 return 0;
14601 }
14602 if ( zversion >= 0x255 )
14603 {
14604 if ( section_version >= 14 )
14605 {
14606 //2.55 starts here
14607 if(!p_getc(&tempdmap.sideview,f))
14608 {
14609 return 0;
14610 }
14611 if(!p_igetw(&tempdmap.script,f))
14612 {
14613 return 0;
14614 }
14615 for ( int32_t q = 0; q < 8; q++ )
14616 {
14617 if(!p_igetl(&tempdmap.initD[q],f))
14618 {
14619 return 0;
14620 }
14621
14622 }
14623 for ( int32_t q = 0; q < 8; q++ )
14624 {
14625 for ( int32_t w = 0; w < 65; w++ )
14626 {
14627 if (!p_getc(&tempdmap.initD_label[q][w],f))
14628 {
14629 return 0;
14630 }
14631 }
14632 }
14633 if(!p_igetw(&tempdmap.active_sub_script,f))
14634 {
14635 return 0;
14636 }
14637 if(!p_igetw(&tempdmap.passive_sub_script,f))
14638 {
14639 return 0;
14640 }
14641 for(int32_t q = 0; q < 8; ++q)
14642 {
14643 if(!p_igetl(&tempdmap.sub_initD[q],f))
14644 {
14645 return 0;
14646 }
14647 }
14648 for(int32_t q = 0; q < 8; ++q)
14649 {
14650 for(int32_t w = 0; w < 65; ++w)
14651 {
14652 if(!p_getc(&tempdmap.sub_initD_label[q][w],f))
14653 {
14654 return 0;
14655 }
14656 }
14657 }
14658 if(!p_igetw(&tempdmap.onmap_script,f))
14659 {
14660 return 0;
14661 }
14662 for(int32_t q = 0; q < 8; ++q)
14663 {
14664 if(!p_igetl(&tempdmap.onmap_initD[q],f))
14665 {
14666 return 0;
14667 }
14668 }
14669 for(int32_t q = 0; q < 8; ++q)
14670 {
14671 for(int32_t w = 0; w < 65; ++w)
14672 {
14673 if(!p_getc(&tempdmap.onmap_initD_label[q][w],f))
14674 {
14675 return 0;
14676 }
14677 }
14678 }
14679 if (!p_igetw(&tempdmap.mirrorDMap, f))
14680 {
14681 return 0;
14682 }
14683 if (!p_igetl(&tempdmap.tmusic_loop_start, f))
14684 {
14685 return 0;
14686 }
14687 if (!p_igetl(&tempdmap.tmusic_loop_end, f))
14688 {
14689 return 0;
14690 }
14691 if (!p_igetl(&tempdmap.tmusic_xfade_in, f))
14692 {
14693 return 0;
14694 }
14695 if (!p_igetl(&tempdmap.tmusic_xfade_out, f))
14696 {
14697 return 0;
14698 }
14699 }
14700 }
14701 DMaps[i].clear();
14702 DMaps[i] = tempdmap;
14703 }
14704
14705 return 1;
14706 }
14707
14708
14709
14710 int32_t writeonedmap(PACKFILE *f, int32_t i)
14711 {
14712
14713 dword section_version=V_DMAPS;
14714 int32_t zversion = ZELDA_VERSION;
14715 int32_t zbuild = VERSION_BUILD;
14716
14717
14718 //section version info
14719 if(!p_iputl(V_ZDMAP,f))
14720 {
14721 return 0;
14722 }
14723 if(!p_iputl(zversion,f))
14724 {
14725 return 0;
14726 }
14727 if(!p_iputl(zbuild,f))
14728 {
14729 return 0;
14730 }
14731 if(!p_iputw(section_version,f))
14732 {
14733 new_return(2);
14734 }
14735
14736 if(!write_deprecated_section_cversion(section_version, f))
14737 {
14738 new_return(3);
14739 }
14740
14741
14742
14743 if(!p_putc(DMaps[i].map,f))
14744 {
14745 new_return(6);
14746 }
14747
14748 if(!p_iputw(DMaps[i].level,f))
14749 {
14750 new_return(7);
14751 }
14752
14753 if(!p_putc(DMaps[i].xoff,f))
14754 {
14755 new_return(8);
14756 }
14757
14758 if(!p_putc(DMaps[i].compass,f))
14759 {
14760 new_return(9);
14761 }
14762
14763 if(!p_iputw(DMaps[i].color,f))
14764 {
14765 new_return(10);
14766 }
14767
14768 if(!p_putc(DMaps[i].midi,f))
14769 {
14770 new_return(11);
14771 }
14772
14773 if(!p_putc(DMaps[i].cont,f))
14774 {
14775 new_return(12);
14776 }
14777
14778 if(!p_putc(DMaps[i].type,f))
14779 {
14780 new_return(13);
14781 }
14782
14783 for(int32_t j=0; j<8; j++)
14784 {
14785 if(!p_putc(DMaps[i].grid[j],f))
14786 {
14787 new_return(14);
14788 }
14789 }
14790
14791 //16
14792 if(!pfwrite(&DMaps[i].name,sizeof(DMaps[0].name),f))
14793 {
14794 new_return(15);
14795 }
14796
14797 if(!pfwrite(&DMaps[i].title,sizeof(DMaps[0].title),f))
14798 {
14799 new_return(16);
14800 }
14801
14802 if(!pfwrite(&DMaps[i].intro,sizeof(DMaps[0].intro),f))
14803 {
14804 new_return(17);
14805 }
14806
14807 if(!p_iputl(DMaps[i].minimap_tile[0],f))
14808 {
14809 new_return(18);
14810 }
14811
14812 if(!p_putc(DMaps[i].minimap_cset[0],f))
14813 {
14814 new_return(19);
14815 }
14816
14817 if(!p_iputl(DMaps[i].minimap_tile[1],f))
14818 {
14819 new_return(20);
14820 }
14821
14822 if(!p_putc(DMaps[i].minimap_cset[1],f))
14823 {
14824 new_return(21);
14825 }
14826
14827 if(!p_iputl(DMaps[i].largemap_tile[0],f))
14828 {
14829 new_return(22);
14830 }
14831
14832 if(!p_putc(DMaps[i].largemap_cset[0],f))
14833 {
14834 new_return(23);
14835 }
14836
14837 if(!p_iputl(DMaps[i].largemap_tile[1],f))
14838 {
14839 new_return(24);
14840 }
14841
14842 if(!p_putc(DMaps[i].largemap_cset[1],f))
14843 {
14844 new_return(25);
14845 }
14846
14847 if(!pfwrite(&DMaps[i].tmusic,sizeof(DMaps[0].tmusic),f))
14848 {
14849 new_return(26);
14850 }
14851
14852 if(!p_putc(DMaps[i].tmusictrack,f))
14853 {
14854 new_return(25);
14855 }
14856
14857 if(!p_putc(DMaps[i].active_subscreen,f))
14858 {
14859 new_return(26);
14860 }
14861
14862 if(!p_putc(DMaps[i].passive_subscreen,f))
14863 {
14864 new_return(27);
14865 }
14866
14867 byte disabled[32];
14868 memset(disabled,0,32);
14869
14870 for(int32_t j=0; j<MAXITEMS; j++)
14871 {
14872 if(DMaps[i].disableditems[j])
14873 {
14874 disabled[j/8] |= (1 << (j%8));
14875 }
14876 }
14877
14878 if(!pfwrite(disabled,32,f))
14879 {
14880 new_return(28);
14881 }
14882
14883 if(!p_iputl(DMaps[i].flags,f))
14884 {
14885 new_return(29);
14886 }
14887 if(!p_putc(DMaps[i].sideview,f))
14888 {
14889 new_return(30);
14890 }
14891 if(!p_iputw(DMaps[i].script,f))
14892 {
14893 new_return(31);
14894 }
14895 for ( int32_t q = 0; q < 8; q++ )
14896 {
14897 if(!p_iputl(DMaps[i].initD[q],f))
14898 {
14899 new_return(32);
14900 }
14901
14902 }
14903 for ( int32_t q = 0; q < 8; q++ )
14904 {
14905 for ( int32_t w = 0; w < 65; w++ )
14906 {
14907 if (!p_putc(DMaps[i].initD_label[q][w],f))
14908 {
14909 new_return(33);
14910 }
14911 }
14912 }
14913 if(!p_iputw(DMaps[i].active_sub_script,f))
14914 {
14915 new_return(34);
14916 }
14917 if(!p_iputw(DMaps[i].passive_sub_script,f))
14918 {
14919 new_return(35);
14920 }
14921 for(int32_t q = 0; q < 8; ++q)
14922 {
14923 if(!p_iputl(DMaps[i].sub_initD[q],f))
14924 {
14925 new_return(36);
14926 }
14927 }
14928 for(int32_t q = 0; q < 8; ++q)
14929 {
14930 for(int32_t w = 0; w < 65; ++w)
14931 {
14932 if(!p_putc(DMaps[i].sub_initD_label[q][w],f))
14933 {
14934 new_return(37);
14935 }
14936 }
14937 }
14938 if(!p_iputw(DMaps[i].onmap_script,f))
14939 {
14940 new_return(35);
14941 }
14942 for(int32_t q = 0; q < 8; ++q)
14943 {
14944 if(!p_iputl(DMaps[i].onmap_initD[q],f))
14945 {
14946 new_return(36);
14947 }
14948 }
14949 for(int32_t q = 0; q < 8; ++q)
14950 {
14951 for(int32_t w = 0; w < 65; ++w)
14952 {
14953 if(!p_putc(DMaps[i].onmap_initD_label[q][w],f))
14954 {
14955 new_return(37);
14956 }
14957 }
14958 }
14959 if (!p_iputw(DMaps[i].mirrorDMap, f))
14960 {
14961 new_return(38);
14962 }
14963 if (!p_iputl(DMaps[i].tmusic_loop_start, f))
14964 {
14965 new_return(39);
14966 }
14967 if (!p_iputl(DMaps[i].tmusic_loop_end, f))
14968 {
14969 new_return(40);
14970 }
14971 if (!p_iputl(DMaps[i].tmusic_xfade_in, f))
14972 {
14973 new_return(41);
14974 }
14975 if (!p_iputl(DMaps[i].tmusic_xfade_out, f))
14976 {
14977 new_return(42);
14978 }
14979
14980 return 1;
14981 }
14982
14983
14984 int32_t readonedmap(PACKFILE *f, int32_t index)
14985 {
14986 dword section_version = 0;
14987 int32_t zversion = 0;
14988 int32_t zbuild = 0;
14989 dmap tempdmap{};
14990 int32_t datatype_version = 0;
14991 int32_t first = 0;
14992 int32_t last = 0;
14993 int32_t max = 0;
14994 int32_t count = 0;
14995
14996 //char dmapstring[64]={0};
14997 //section version info
14998 if(!p_igetl(&datatype_version,f))
14999 {
15000 return 0;
15001 }
15002 if ( datatype_version < 0 )
15003 {
15004 if(!p_igetl(&zversion,f))
15005 {
15006 return 0;
15007 }
15008 }
15009 else
15010 {
15011 zversion = datatype_version;
15012 }
15013 if(!p_igetl(&zbuild,f))
15014 {
15015 return 0;
15016 }
15017
15018 if(!p_igetw(&section_version,f))
15019 {
15020 return 0;
15021 }
15022
15023 if(!read_deprecated_section_cversion(f))
15024 {
15025 return 0;
15026 }
15027 al_trace("readonedmap section_version: %d\n", section_version);
15028
15029
15030 if ( datatype_version < 0 )
15031 {
15032 if(!p_igetl(&max,f))
15033 {
15034 return 0;
15035 }
15036 if(!p_igetl(&first,f))
15037 {
15038 return 0;
15039 }
15040 if(!p_igetl(&last,f))
15041 {
15042 return 0;
15043 }
15044 if(!p_igetl(&count,f))
15045 {
15046 return 0;
15047 }
15048 }
15049 if ( zversion > ZELDA_VERSION )
15050 {
15051 al_trace("Cannot read .zdmap packfile made in ZC version (%x) in this version of ZC (%x)\n", zversion, ZELDA_VERSION);
15052 return 0;
15053 }
15054 else if (( section_version > V_DMAPS ))
15055 {
15056 al_trace("Cannot read .zdmap packfile made using V_DMAPS (%d)\n", section_version);
15057 return 0;
15058 }
15059 else
15060 {
15061 al_trace("Reading a .zdmap packfile made in ZC Version: %x, Build: %d\n", zversion, zbuild);
15062 }
15063 //if(!pfread(&dmapstring, 64, f))
15064 //{
15065 // return 0;
15066 //}
15067
15068
15069
15070
15071 if(!p_getc(&tempdmap.map,f))
15072 {
15073 return 0;
15074 }
15075
15076 if(!p_igetw(&tempdmap.level,f))
15077 {
15078 return 0;
15079 }
15080
15081 if(!p_getc(&tempdmap.xoff,f))
15082 {
15083 return 0;
15084 }
15085
15086 if(!p_getc(&tempdmap.compass,f))
15087 {
15088 return 0;
15089 }
15090
15091 if(!p_igetw(&tempdmap.color,f))
15092 {
15093 return 0;
15094 }
15095
15096 if(!p_getc(&tempdmap.midi,f))
15097 {
15098 return 0;
15099 }
15100
15101 if(!p_getc(&tempdmap.cont,f))
15102 {
15103 return 0;
15104 }
15105
15106 if(!p_getc(&tempdmap.type,f))
15107 {
15108 return 0;
15109 }
15110
15111 for(int32_t j=0; j<8; j++)
15112 {
15113 if(!p_getc(&tempdmap.grid[j],f))
15114 {
15115 return 0;
15116 }
15117 }
15118
15119 //16
15120 if(!pfread(&tempdmap.name,sizeof(DMaps[0].name),f))
15121 {
15122 return 0;
15123 }
15124
15125 if (section_version<20)
15126 {
15127 char title[22];
15128 if (!p_getstr(title, sizeof(title) - 1, f))
15129 {
15130 return 0;
15131 }
15132 tempdmap.title.assign(title);
15133 }
15134 else
15135 {
15136 if (!p_getwstr(&tempdmap.title, f))
15137 {
15138 return 0;
15139 }
15140 }
15141
15142 if(!pfread(&tempdmap.title,sizeof(DMaps[0].title),f))
15143 {
15144 return 0;
15145 }
15146
15147 if(!pfread(&tempdmap.intro,sizeof(DMaps[0].intro),f))
15148 {
15149 return 0;
15150 }
15151
15152 if(!p_igetl(&tempdmap.minimap_tile[0],f))
15153 {
15154 return 0;
15155 }
15156
15157 if(!p_getc(&tempdmap.minimap_cset[0],f))
15158 {
15159 return 0;
15160 }
15161
15162 if(!p_igetl(&tempdmap.minimap_tile[1],f))
15163 {
15164 return 0;
15165 }
15166
15167 if(!p_getc(&tempdmap.minimap_cset[1],f))
15168 {
15169 return 0;
15170 }
15171
15172 if(!p_igetl(&tempdmap.largemap_tile[0],f))
15173 {
15174 return 0;
15175 }
15176
15177 if(!p_getc(&tempdmap.largemap_cset[0],f))
15178 {
15179 return 0;
15180 }
15181
15182 if(!p_igetl(&tempdmap.largemap_tile[1],f))
15183 {
15184 return 0;
15185 }
15186
15187 if(!p_getc(&tempdmap.largemap_cset[1],f))
15188 {
15189 return 0;
15190 }
15191
15192 if(!pfread(&tempdmap.tmusic,sizeof(DMaps[0].tmusic),f))
15193 {
15194 return 0;
15195 }
15196
15197 if(!p_getc(&tempdmap.tmusictrack,f))
15198 {
15199 return 0;
15200 }
15201
15202 if(!p_getc(&tempdmap.active_subscreen,f))
15203 {
15204 return 0;
15205 }
15206
15207 if(!p_getc(&tempdmap.passive_subscreen,f))
15208 {
15209 return 0;
15210 }
15211
15212 byte disabled[32];
15213 memset(disabled,0,32);
15214
15215 if(!pfread(&disabled, 32, f)) return 0;
15216
15217 for(int32_t j=0; j<MAXITEMS; j++)
15218 {
15219 if(disabled[j/8] & (1 << (j%8))) tempdmap.disableditems[j]=1;
15220 else tempdmap.disableditems[j]=0;
15221 }
15222
15223
15224 if(!p_igetl(&tempdmap.flags,f))
15225 {
15226 return 0;
15227 }
15228 if ( zversion >= 0x255 )
15229 {
15230 if ( section_version >= 14 )
15231 {
15232 //2.55 starts here
15233 if(!p_getc(&tempdmap.sideview,f))
15234 {
15235 return 0;
15236 }
15237 if(!p_igetw(&tempdmap.script,f))
15238 {
15239 return 0;
15240 }
15241 for ( int32_t q = 0; q < 8; q++ )
15242 {
15243 if(!p_igetl(&tempdmap.initD[q],f))
15244 {
15245 return 0;
15246 }
15247
15248 }
15249 for ( int32_t q = 0; q < 8; q++ )
15250 {
15251 for ( int32_t w = 0; w < 65; w++ )
15252 {
15253 if (!p_getc(&tempdmap.initD_label[q][w],f))
15254 {
15255 return 0;
15256 }
15257 }
15258 }
15259 if(!p_igetw(&tempdmap.active_sub_script,f))
15260 {
15261 return 0;
15262 }
15263 if(!p_igetw(&tempdmap.passive_sub_script,f))
15264 {
15265 return 0;
15266 }
15267 for(int32_t q = 0; q < 8; ++q)
15268 {
15269 if(!p_igetl(&tempdmap.sub_initD[q],f))
15270 {
15271 return 0;
15272 }
15273 }
15274 for(int32_t q = 0; q < 8; ++q)
15275 {
15276 for(int32_t w = 0; w < 65; ++w)
15277 {
15278 if(!p_getc(&tempdmap.sub_initD_label[q][w],f))
15279 {
15280 return 0;
15281 }
15282 }
15283 }
15284 if(!p_igetw(&tempdmap.onmap_script,f))
15285 {
15286 return 0;
15287 }
15288 for(int32_t q = 0; q < 8; ++q)
15289 {
15290 if(!p_igetl(&tempdmap.onmap_initD[q],f))
15291 {
15292 return 0;
15293 }
15294 }
15295 for(int32_t q = 0; q < 8; ++q)
15296 {
15297 for(int32_t w = 0; w < 65; ++w)
15298 {
15299 if(!p_getc(&tempdmap.onmap_initD_label[q][w],f))
15300 {
15301 return 0;
15302 }
15303 }
15304 }
15305 if (!p_igetw(&tempdmap.mirrorDMap, f))
15306 {
15307 return 0;
15308 }
15309 if (!p_igetl(&tempdmap.tmusic_loop_start, f))
15310 {
15311 return 0;
15312 }
15313 if (!p_igetl(&tempdmap.tmusic_loop_end, f))
15314 {
15315 return 0;
15316 }
15317 if (!p_igetl(&tempdmap.tmusic_xfade_in, f))
15318 {
15319 return 0;
15320 }
15321 if (!p_igetl(&tempdmap.tmusic_xfade_out, f))
15322 {
15323 return 0;
15324 }
15325 }
15326 }
15327 DMaps[index] = tempdmap;
15328
15329 return 1;
15330 }
15331
15332 int32_t onDmaps()
15333 {
15334 DMapListerDialog(0).show();
15335 return D_O_K;
15336 }
15337
15338 int32_t onRegions()
15339 {
15340 bool valid = false;
15341 for (int i = 0; i < MAPSCRS; i++)
15342 {
15343 if (Map.Scr(i)->is_valid())
15344 {
15345 valid = true;
15346 break;
15347 }
15348 }
15349
15350 if (valid)
15351 {
15352 call_edit_region_dialog(Map.getCurrMap());
15353 Map.regions_mark_dirty();
15354 }
15355 else
15356 {
15357 InfoDialog("Invalid maps", "There must be at least one valid screen in a map to configure regions").show();
15358 }
15359
15360 return D_O_K;
15361 }
15362
15363 int32_t onMidis()
15364 {
15365 stopMusic();
15366 MidiListerDialog().show();
15367 return D_O_K;
15368 }
15369
15370 static DIALOG editmusic_dlg[] =
15371 {
15372 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
15373 { jwin_win_proc, 24, 20, 273, 189, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Music Specs", NULL, NULL },
15374 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15375 // 2
15376 { jwin_text_proc, 56, 94-16, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Music:", NULL, NULL },
15377 { jwin_text_proc, 104, 94-16, 48, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15378 { jwin_text_proc, 56, 114, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
15379 { jwin_edit_proc, 104, 114-4, 160, 16, vc(12), vc(1), 0, 0, 19, 0, NULL, NULL, NULL },
15380 { jwin_text_proc, 56, 124-4+12, 56, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Volume:", NULL, NULL },
15381 { jwin_edit_proc, 120, 124-4+12-4, 32, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
15382 // 8
15383 { jwin_check_proc, 176, 124+12-4, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, (void *) "Loop", NULL, NULL },
15384 // 9
15385 { jwin_button_proc, 50, 72-24, 57, 21, vc(14), vc(1), 'l', D_EXIT, 0, 0, (void *) "&Load", NULL, NULL },
15386 { jwin_iconbutton_proc, 116, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_STOPSQUARE, 0, NULL, NULL, NULL },
15387 { jwin_iconbutton_proc, 156, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT, 0, NULL, NULL, NULL },
15388 { jwin_iconbutton_proc, 196, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT2, 0, NULL, NULL, NULL },
15389 { jwin_iconbutton_proc, 236, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT3, 0, NULL, NULL, NULL },
15390 // 14
15391 { jwin_text_proc, 56, 134+4+12, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start:", NULL, NULL },
15392 { jwin_edit_proc, 112, 134+12, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15393 { jwin_text_proc, 176, 134+12+4, 56, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Loop Start:", NULL, NULL },
15394 { jwin_edit_proc, 240, 134+12, 40, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15395 { jwin_text_proc, 176, 144+12+12, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Loop End:", NULL, NULL },
15396 { jwin_edit_proc, 240, 144+12+12-4, 40, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15397 // 20
15398 { jwin_text_proc, 176, 94-16, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Position:", NULL, NULL },
15399 { jwin_text_proc, 217, 94-16, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15400 { jwin_text_proc, 176, 104-8, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Length:", NULL, NULL },
15401 { jwin_text_proc, 216, 104-8, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15402 { jwin_text_proc, 56, 104-8, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Time:", NULL, NULL },
15403 { jwin_text_proc, 104, 104-8, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15404 // 26
15405 { jwin_button_proc, 90, 160+12+12, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
15406 { jwin_button_proc, 170, 160+12+12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
15407 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
15408 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15409 };
15410
15411 int32_t d_musiclist_proc(int32_t msg,DIALOG *d,int32_t c)
15412 {
15413 return jwin_list_proc(msg,d,c);
15414 }
15415
15416 12 static ListData enhancedmusic_list(enhancedmusiclist, &font);
15417
15418 static DIALOG selectmusic_dlg[] =
15419 {
15420 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
15421 12 { jwin_win_proc, 24, 20, 273, 189, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select Enhanced Music", NULL, NULL },
15422 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15423 12 { d_musiclist_proc, 31, 44, 164, (1+16)*8, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &enhancedmusic_list, NULL, NULL },
15424 12 { jwin_button_proc, 90, 160+12+12, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
15425 12 { jwin_button_proc, 170, 160+12+12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
15426 12 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_DEL, (void *) close_dlg, NULL, NULL },
15427 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15428 };
15429
15430 const char *warptypelist(int32_t index, int32_t *list_size)
15431 {
15432 if(index>=0)
15433 {
15434 if(index>=MAXWARPTYPES)
15435 index=MAXWARPTYPES-1;
15436
15437 return warptype_string[index];
15438 }
15439
15440 *list_size=MAXWARPTYPES;
15441 // *list_size=6;
15442 return NULL;
15443 }
15444
15445 const char *warpeffectlist(int32_t index, int32_t *list_size)
15446 {
15447 if(index>=0)
15448 {
15449 if(index>=MAXWARPEFFECTS)
15450 index=MAXWARPEFFECTS-1;
15451
15452 return warpeffect_string[index];
15453 }
15454
15455 *list_size=MAXWARPEFFECTS;
15456 return NULL;
15457 }
15458
15459 static int32_t warp1_list[] =
15460 {
15461 2,3,4,5,6,7,8,9,10,11,12,13,53,54,63,67,-1
15462 };
15463
15464 static int32_t warp2_list[] =
15465 {
15466 17,18,19,20,21,22,23,24,25,26,27,28,55,56,64,68,-1
15467 };
15468
15469 static int32_t warp3_list[] =
15470 {
15471 29,30,31,32,33,34,35,36,37,38,39,40,57,58,65,69,-1
15472 };
15473
15474 static int32_t warp4_list[] =
15475 {
15476 41,42,43,44,45,46,47,48,49,50,51,52,59,60,66,70,-1
15477 };
15478
15479 static TABPANEL warp_tabs[] =
15480 {
15481 // (text)
15482 { (char *)"A", D_SELECTED, warp1_list, 0, NULL },
15483 { (char *)"B", 0, warp2_list, 0, NULL },
15484 { (char *)"C", 0, warp3_list, 0, NULL },
15485 { (char *)"D", 0, warp4_list, 0, NULL },
15486 { NULL, 0, NULL, 0, NULL }
15487 };
15488
15489 int32_t onTileWarpIndex(int32_t index)
15490 {
15491 int32_t i=-1;
15492
15493 while(warp_tabs[++i].text != NULL)
15494 warp_tabs[i].flags = (i==index ? D_SELECTED : 0);
15495
15496 onTileWarp();
15497 return D_O_K;
15498 }
15499
15500 static char warpr_buf[10];
15501 const char *warprlist(int32_t index, int32_t *list_size)
15502 {
15503 if(index>=0)
15504 {
15505 bound(index,0,3);
15506 sprintf(warpr_buf,"%c",index+0x41);
15507 return warpr_buf;
15508 }
15509
15510 *list_size=4;
15511 return NULL;
15512 }
15513
15514 int32_t d_wflag_proc(int32_t msg,DIALOG *d,int32_t c);
15515
15516 12 static ListData warp_dlg_list(warptypelist, &font);
15517 12 static ListData warp_ret_list(warprlist, &font);
15518
15519 int32_t d_warpdestscrsel_proc(int32_t msg,DIALOG *d,int32_t c)
15520 {
15521 if(msg == MSG_START)
15522 {
15523 d->d1 = -1; //cached val
15524 d->d2 = -1; //cached dmap
15525 d->fg = 0; //cached 'force_16'
15526 }
15527 char* buf = (char*)d->dp;
15528 vector<DIALOG*>* dlgs = (vector<DIALOG*>*)d->dp2;
15529 int* dmap_ptr = (int*) d->dp3;
15530 if(!(buf && dmap_ptr))
15531 return D_O_K;
15532 bool is_overworld = ((DMaps[*dmap_ptr].type&dmfTYPE)==dmOVERW);
15533 int scrw = is_overworld ? 16 : 8, scrh = 9;
15534 const int max = 0x87;
15535 int bufval = zc_xtoi(buf);
15536 int val = vbound(bufval,0,max);
15537 auto& dm = DMaps[*dmap_ptr];
15538 auto val_offset = dm.xoff < 0 ? -dm.xoff : 0;
15539 bool force_16 = d->fg;
15540 if(!is_overworld)
15541 {
15542 if((val&0xF) >= 0x8)
15543 force_16 = true;
15544 else if((val&0xF) < val_offset && (val&0xF0) < 0x80)
15545 force_16 = true;
15546 }
15547 if(force_16) //can't bound, some quests need to warp out of bounds... -Em
15548 {
15549 scrw = 16; //just force show the larger grid instead
15550 val_offset = 0;
15551 }
15552
15553 int xscl = d->w/scrw;
15554 int yscl = d->h/scrh;
15555
15556 int ret = D_O_K;
15557 bool redraw = false;
15558 if(d->d1 != val)
15559 {
15560 redraw = true;
15561 d->d1 = val;
15562 }
15563 if(bufval != val)
15564 {
15565 redraw = true;
15566 sprintf(buf, "%X", val);
15567 }
15568 if(d->d2 != *dmap_ptr)
15569 {
15570 redraw = true;
15571 d->d2 = *dmap_ptr;
15572 }
15573 switch(msg)
15574 {
15575 case MSG_WANTFOCUS:
15576 ret = D_WANTFOCUS;
15577 break;
15578 case MSG_CLICK:
15579 {
15580 d->fg = force_16 ? 1 : 0;
15581 bool redraw2 = false;
15582 while(gui_mouse_b())
15583 {
15584 if(redraw2)
15585 {
15586 broadcast_dialog_message(MSG_DRAW, 0);
15587 redraw2 = false;
15588 }
15589 if(!d->fg && (gui_mouse_b()&2))
15590 {
15591 scrw = 16;
15592 xscl = d->w/scrw;
15593 yscl = d->h/scrh;
15594 val_offset = 0;
15595 d->fg = 1;
15596 redraw2 = true;
15597 }
15598 custom_vsync();
15599 if(!mouse_in_rect(d->x,d->y,d->w,d->h))
15600 continue;
15601 int mx = gui_mouse_x()-d->x, my = gui_mouse_y()-d->y;
15602 int y = vbound(my/yscl,0,scrh-1);
15603 auto offs = y==8 ? 0 : val_offset;
15604 int x = vbound(mx/xscl,offs,scrw-1);
15605 auto val2 = (y*16)+x;
15606 if(val2 > max) //out of bounds in the bottom-right
15607 continue;
15608 val = val2;
15609 if(d->d1 != val)
15610 {
15611 d->d1 = val;
15612 sprintf(buf, "%02X", val);
15613 redraw2 = true;
15614 }
15615 }
15616 redraw = true;
15617 d->fg = 0;
15618 break;
15619 }
15620 case MSG_DRAW:
15621 {
15622 rectfill(screen,d->x,d->y,d->x+d->w-1,d->y+d->h-1,jwin_pal[jcBOX]);
15623 jwin_draw_frame(screen, d->x-2, d->y-2, d->w+4, d->h+4, FR_MENU);
15624 for(int yind = 0; yind < scrh; ++yind)
15625 {
15626 auto gr = (yind < 8 ? dm.grid[yind] : 0);
15627 for(int xind = (yind == 8 ? 0 : val_offset); xind < scrw; ++xind)
15628 {
15629 int screen_index = xind+(yind*16);
15630 if(screen_index > max)
15631 continue;
15632 int fr = FR_MENU;
15633 if(screen_index == d->d1)
15634 fr = FR_GREEN;
15635 else if(!is_overworld && xind < 8 && (gr&(1<<(8-xind-1))))
15636 fr = FR_MENU_INV;
15637 jwin_draw_frame(screen, d->x+(xind*xscl), d->y+(yind*yscl), xscl, yscl, fr);
15638 }
15639 }
15640 break;
15641 }
15642 case MSG_XCHAR:
15643 {
15644 bool on_80 = (val&0xF0) == 0x80;
15645 switch(c>>8)
15646 {
15647 case KEY_UP:
15648 if((val&0xF0) && !(val_offset && on_80 && (val&0xF) < val_offset))
15649 {
15650 val -= 0x10;
15651 redraw = true;
15652 }
15653 ret |= D_USED_CHAR;
15654 break;
15655 case KEY_DOWN:
15656 if((val&0xF0) < ((val&0xF) < 0x8 ? 0x80 : 0x70))
15657 {
15658 val += 0x10;
15659 redraw = true;
15660 }
15661 ret |= D_USED_CHAR;
15662 break;
15663 case KEY_LEFT:
15664 if((val&0xF) > (on_80 ? 0 : val_offset))
15665 {
15666 --val;
15667 redraw = true;
15668 }
15669 ret |= D_USED_CHAR;
15670 break;
15671 case KEY_RIGHT:
15672 if((val&0xF) < scrw-1 && val < 0x87)
15673 {
15674 ++val;
15675 redraw = true;
15676 }
15677 ret |= D_USED_CHAR;
15678 break;
15679 }
15680 if(redraw)
15681 sprintf(buf, "%02X", val);
15682 break;
15683 }
15684 }
15685 if(redraw)
15686 {
15687 if(msg == MSG_IDLE)
15688 broadcast_dialog_message(MSG_DRAW,0);
15689 else
15690 {
15691 d->d1 = d->d2 = -1;
15692 object_message(d,MSG_IDLE,0);
15693 }
15694 }
15695
15696 return ret;
15697 }
15698
15699 int32_t tilewarpdmapxy[6] = {170,38,170,18,170,27};
15700 static DIALOG tilewarp_dlg[] =
15701 {
15702 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
15703 12 { jwin_win_proc, 0, 0, 302, 178, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
15704 12 { jwin_rtext_proc, 89, 43, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Type:", NULL, NULL },
15705 12 { jwin_rtext_proc, 57, 62, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
15706 12 { jwin_rtext_proc, 57, 80, 64, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Screen: 0x", NULL, NULL },
15707 12 { jwin_droplist_proc, 91, 38, 193, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_dlg_list, NULL, NULL },
15708 //5
15709 12 { d_dropdmaplist_proc, 59, 57, 225, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &dmap_list, NULL, tilewarpdmapxy },
15710 12 { jwin_hexedit_proc, 59, 76, 24, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
15711 12 { jwin_button_proc, 61, 152, 41, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
15712 12 { jwin_button_proc, 121, 152, 41, 21, vc(14), vc(1), 'g', D_EXIT, 0, 0, (void *) "&Go", NULL, NULL },
15713 12 { jwin_button_proc, 181, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
15714 //10
15715 12 { jwin_rtext_proc, 82, 95, 100, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Use Warp Return:", NULL, NULL },
15716 12 { jwin_droplist_proc, 10, 105, 72, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_ret_list, NULL, NULL },
15717 12 { jwin_check_proc, 10, 125, 129, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Combos Carry Over", NULL, NULL },
15718 12 { d_warpdestscrsel_proc, 90, 76, 8*16, 8*9, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15719 12 { jwin_button_proc, 59, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "A", NULL, NULL },
15720 //15
15721 12 { jwin_button_proc, 109, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "B", NULL, NULL },
15722 12 { jwin_button_proc, 159, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "C", NULL, NULL },
15723 12 { jwin_button_proc, 209, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "D", NULL, NULL },
15724 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15725 };
15726
15727 int32_t sidewarpdmapxy[6] = {170,38,170,18,170,27};
15728 static DIALOG sidewarp_dlg[] =
15729 {
15730 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
15731 12 { jwin_win_proc, 0, 0, 302, 178, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
15732 12 { jwin_rtext_proc, 89, 43, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Type:", NULL, NULL },
15733 12 { jwin_rtext_proc, 57, 62, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
15734 12 { jwin_rtext_proc, 57, 80, 64, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Screen: 0x", NULL, NULL },
15735 12 { jwin_droplist_proc, 91, 38, 193, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_dlg_list, NULL, NULL },
15736 //5
15737 12 { d_dropdmaplist_proc, 59, 57, 225, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &dmap_list, NULL, tilewarpdmapxy },
15738 12 { jwin_hexedit_proc, 59, 76, 24, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
15739 12 { jwin_button_proc, 61, 152, 41, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
15740 12 { jwin_button_proc, 121, 152, 41, 21, vc(14), vc(1), 'g', D_EXIT, 0, 0, (void *) "&Go", NULL, NULL },
15741 12 { jwin_button_proc, 181, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
15742 //10
15743 12 { jwin_rtext_proc, 82, 95, 100, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Use Warp Return:", NULL, NULL },
15744 12 { jwin_droplist_proc, 10, 105, 72, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_ret_list, NULL, NULL },
15745 12 { jwin_check_proc, 10, 125, 129, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Combos Carry Over", NULL, NULL },
15746 12 { d_warpdestscrsel_proc, 90, 76, 8*16, 8*9, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15747 12 { jwin_button_proc, 59, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "A", NULL, NULL },
15748 //15
15749 12 { jwin_button_proc, 109, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "B", NULL, NULL },
15750 12 { jwin_button_proc, 159, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "C", NULL, NULL },
15751 12 { jwin_button_proc, 209, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "D", NULL, NULL },
15752 // 18
15753 12 { d_wflag_proc, 18, 17, 15, 8, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
15754 12 { d_wflag_proc, 18, 47, 15, 8, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
15755 // 20
15756 12 { d_wflag_proc, 8, 27, 8, 15, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
15757 12 { d_wflag_proc, 37, 27, 8, 15, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
15758
15759 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15760 };
15761
15762 int32_t warpringxy[6] = {170,38,170,18,170,27};
15763 static DIALOG warpring_warp_dlg[] =
15764 {
15765 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
15766 12 { jwin_win_proc, 0, 0, 302, 145, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
15767 12 { jwin_rtext_proc, 57, 25, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
15768 12 { jwin_rtext_proc, 57, 46, 64, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Screen: 0x", NULL, NULL },
15769 12 { d_dropdmaplist_proc, 59, 19, 225, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &dmap_list, NULL, warpringxy },
15770 12 { jwin_hexedit_proc, 59, 39, 24, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
15771 // 5
15772 12 { jwin_button_proc, 61, 115, 41, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
15773 12 { jwin_button_proc, 121, 115, 41, 21, vc(14), vc(1), 'g', D_EXIT, 0, 0, (void *) "&Go", NULL, NULL },
15774 12 { jwin_button_proc, 181, 115, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
15775 12 { d_warpdestscrsel_proc, 90, 39, 8*16, 8*9, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15776
15777 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15778 };
15779
15780 // Side warp flag procedure
15781 int32_t d_wflag_proc(int32_t msg,DIALOG *d,int32_t)
15782 {
15783 int32_t ret = D_O_K;
15784 switch(msg)
15785 {
15786 case MSG_DRAW:
15787 {
15788 int32_t c2=(d->flags&D_SELECTED)?d->fg:d->bg;
15789
15790 if(d->d1==1)
15791 {
15792 jwin_draw_frame(screen,d->x,d->y,d->w,d->h, FR_DEEP);
15793 rectfill(screen,d->x+2, d->y+2, d->x+d->w-3, d->y+d->h-3,c2);
15794
15795 if(d->flags&D_SELECTED)
15796 {
15797 int32_t e=d->d2&3;
15798
15799 if(d->w>d->h)
15800 textprintf_centre_ex(screen,get_zc_font(font_lfont_l), d->x+(d->w/2),d->y,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
15801 else
15802 textprintf_centre_ex(screen,get_zc_font(font_lfont_l), d->x+(d->w/2),d->y+(d->h/2)-4,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
15803 }
15804
15805 }
15806 else
15807 {
15808 rectfill(screen,d->x, d->y, d->x+d->w-1, d->y+d->h-1,c2);
15809 }
15810 }
15811 break;
15812
15813 case MSG_CLICK:
15814 {
15815 if(d->flags & D_DISABLED)
15816 return D_O_K;
15817 bool rclick = gui_mouse_b() & 2;
15818 if(d->d1==1)
15819 {
15820 if(!(d->flags&D_SELECTED))
15821 {
15822 d->flags |= D_SELECTED;
15823 d->d2 &= 0x80;
15824 if (rclick)
15825 d->d2 |= 3;
15826 }
15827 else
15828 {
15829 if((d->d2&3) == (rclick?0:3))
15830 {
15831 d->flags ^= D_SELECTED;
15832 d->d2 &= 0x80;
15833 }
15834 else
15835 {
15836 int32_t f = d->d2&3;
15837 d->d2 &= 0x80;
15838 f += rclick ? -1 : 1;
15839 d->d2 |= f;
15840 }
15841 }
15842 }
15843 else
15844 {
15845 d->flags^=D_SELECTED;
15846 }
15847
15848 int32_t c2=(d->flags&D_SELECTED)?d->fg:d->bg;
15849
15850 if(d->d1==1)
15851 {
15852 jwin_draw_frame(screen,d->x,d->y,d->w,d->h, FR_DEEP);
15853 rectfill(screen,d->x+2, d->y+2, d->x+d->w-3, d->y+d->h-3,c2);
15854
15855 if(d->flags&D_SELECTED)
15856 {
15857 int32_t e=d->d2&3;
15858
15859 if(d->w>d->h)
15860 textprintf_centre_ex(screen,get_zc_font(font_lfont_l),d->x+(d->w/2),d->y,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
15861 else
15862 textprintf_centre_ex(screen,get_zc_font(font_lfont_l),d->x+(d->w/2),d->y+(d->h/2)-4,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
15863 }
15864 }
15865 else
15866 {
15867 rectfill(screen,d->x, d->y, d->x+d->w-1, d->y+d->h-1,c2);
15868 }
15869
15870
15871 while(gui_mouse_b())
15872 {
15873 /* do nothing */
15874 rest(1);
15875 }
15876 ret = D_REDRAWME;
15877 }
15878 break;
15879 }
15880
15881 return ret;
15882 }
15883
15884 int32_t d_dmapscrsel_proc(int32_t msg,DIALOG *d,int32_t c)
15885 {
15886 //these are here to bypass compiler warnings about unused arguments
15887 c=c;
15888
15889 int32_t ret = D_O_K;
15890
15891 switch(msg)
15892 {
15893 case MSG_CLICK:
15894 sprintf((char*)((d+2)->dp),"%X%X",vbound((gui_mouse_y()-d->y)/4,0,7),vbound((gui_mouse_x()-d->x)/(((DMaps[(d-1)->d1].type&dmfTYPE)==1)?4:8),0,(((DMaps[(d-1)->d1].type&dmfTYPE)==1)?15:7)));
15895 object_message(d+2, MSG_DRAW, 0);
15896 break;
15897 }
15898
15899 return ret;
15900 }
15901
15902 int32_t warpdestsel_x=-1;
15903 int32_t warpdestsel_y=-1;
15904 int32_t warpdestmap=-1;
15905 int32_t warpdestscr=-1;
15906
15907 int32_t jwin_minibutton_proc(int32_t msg,DIALOG *d,int32_t c)
15908 {
15909 switch(msg)
15910 {
15911 case MSG_DRAW:
15912 jwin_draw_text_button(screen, d->x, d->y, d->w, d->h, (char*)d->dp, d->flags, false);
15913 return D_O_K;
15914 break;
15915 }
15916
15917 return jwin_button_proc(msg,d,c);
15918 }
15919
15920 int32_t d_triggerbutton_proc(int32_t msg,DIALOG *d,int32_t c)
15921 {
15922 static BITMAP *dummy=create_bitmap_ex(8, 1, 1);
15923
15924 switch(msg)
15925 {
15926 case MSG_START:
15927 d->w=gui_textout_ln(dummy, font, (uint8_t *)d->dp, 0, 0, jwin_pal[jcMEDDARK], -1, 0)+4;
15928 d->h=text_height(font)+5;
15929 break;
15930
15931 case MSG_GOTFOCUS:
15932 d->flags&=~D_GOTFOCUS;
15933 break;
15934
15935 }
15936
15937 return jwin_minibutton_proc(msg,d,c);
15938 }
15939
15940 int32_t d_alltriggerbutton_proc(int32_t msg,DIALOG *d,int32_t c)
15941 {
15942 DIALOG *temp_d;
15943 int32_t ret=d_triggerbutton_proc(msg,d,c);
15944
15945 switch(msg)
15946 {
15947 case MSG_CLICK:
15948 temp_d=d-1;
15949
15950 while(temp_d->proc==d_triggerbutton_proc)
15951 {
15952 temp_d->flags&=~D_SELECTED;
15953 temp_d->flags|=D_DIRTY;
15954
15955 if(d->flags&D_SELECTED)
15956 {
15957 temp_d->flags|=D_SELECTED;
15958 }
15959
15960 --temp_d;
15961 }
15962
15963 break;
15964 }
15965
15966 return ret;
15967 }
15968
15969 int32_t d_ticsedit_proc(int32_t msg,DIALOG *d,int32_t c)
15970 {
15971 int32_t ret = jwin_edit_proc(msg,d,c);
15972
15973 if(msg==MSG_DRAW)
15974 {
15975 int32_t tics=vbound(atoi((char*)d->dp),0,65535);
15976 sprintf((char*)(d+1)->dp,"%s %s",ticksstr(tics),tics==0?"(No Timed Warp)":" ");
15977 object_message(d+1,MSG_DRAW,c);
15978 }
15979
15980 return ret;
15981 }
15982
15983 12 static ListData warp_effect_list(warpeffectlist,&font);
15984
15985 struct tw_data
15986 {
15987 int twscr[4], twtype[4], twdmap[4], wret[4];
15988 byte oflags;
15989 optional<uint> loaded;
15990
15991 tw_data(mapscr* scr) {load_scr(scr);}
15992 void load_scr(mapscr* scr)
15993 {
15994 oflags = scr->tilewarpoverlayflags;
15995 for(int q = 0; q < 4; ++q)
15996 {
15997 twscr[q] = scr->tilewarpscr[q];
15998 twtype[q] = scr->tilewarptype[q];
15999 twdmap[q] = scr->tilewarpdmap[q];
16000 wret[q] = (scr->warpreturnc >> (2*q))&3;
16001 }
16002 loaded.reset();
16003 }
16004 void save_scr(mapscr* scr)
16005 {
16006 saved=false;
16007 scr->tilewarpoverlayflags = oflags;
16008 scr->warpreturnc = scr->warpreturnc & 0xFF00;
16009 for(int q = 0; q < 4; ++q)
16010 {
16011 scr->tilewarpscr[q] = twscr[q];
16012 scr->tilewarptype[q] = twtype[q];
16013 scr->tilewarpdmap[q] = twdmap[q];
16014 scr->warpreturnc |= wret[q] << (2*q);
16015 }
16016 }
16017
16018 void load(uint ind)
16019 {
16020 if(ind >= 4) return;
16021 loaded = ind;
16022 tilewarp_dlg[4].d1 = twtype[ind];
16023 tilewarp_dlg[5].d1 = twdmap[ind];
16024 char* buf = (char*)tilewarp_dlg[6].dp;
16025 sprintf(buf,"%02X",twscr[ind]);
16026 tilewarp_dlg[11].d1 = wret[ind];
16027 SETFLAG(tilewarp_dlg[12].flags, D_SELECTED, get_bit(&oflags,ind));
16028 for(int q = 0; q < 4; ++q)
16029 SETFLAG(tilewarp_dlg[14+q].flags,(D_SELECTED|D_DISABLED),q==ind);
16030 }
16031 void save(uint ind)
16032 {
16033 if(ind >= 4) return;
16034 twtype[ind] = tilewarp_dlg[4].d1;
16035 twdmap[ind] = tilewarp_dlg[5].d1;
16036 char* buf = (char*)tilewarp_dlg[6].dp;
16037 twscr[ind] = vbound(zc_xtoi(buf),0x00,0x87);
16038 wret[ind] = tilewarp_dlg[11].d1;
16039 set_bit(&oflags, ind, tilewarp_dlg[12].flags & D_SELECTED);
16040 }
16041 void save()
16042 {
16043 if(loaded)
16044 save(*loaded);
16045 }
16046 void swap(uint ind)
16047 {
16048 if(ind >= 4) return;
16049 if(loaded)
16050 {
16051 save(*loaded);
16052 if(*loaded == ind)
16053 return;
16054 }
16055 load(ind);
16056 }
16057 };
16058 int32_t onTileWarp()
16059 {
16060 restore_mouse();
16061 tilewarp_dlg[0].dp=(void *) "Tile Warp";
16062 tilewarp_dlg[0].dp2=get_zc_font(font_lfont);
16063
16064 mapscr* mptr = Map.CurrScr();
16065 char buf[10];
16066 tilewarp_dlg[6].dp=buf;
16067 tilewarp_dlg[13].dp = buf;
16068 tilewarp_dlg[13].dp3 = &tilewarp_dlg[5].d1;
16069
16070 vector<DIALOG*> dlgs;
16071 dlgs.push_back(&tilewarp_dlg[5]);
16072 dlgs.push_back(&tilewarp_dlg[6]);
16073 tilewarp_dlg[13].dp2 = &dlgs;
16074
16075 tw_data data(mptr);
16076 data.load(0);
16077
16078 dmap_list_size=MAXDMAPS;
16079 dmap_list_zero=true;
16080
16081 large_dialog(tilewarp_dlg);
16082
16083 bool running = true;
16084 int ret;
16085 do
16086 {
16087 ret = do_zqdialog(tilewarp_dlg,-1);
16088 switch(ret)
16089 {
16090 // OK, GO
16091 case 7: case 8:
16092 running = false;
16093 data.save();
16094 data.save_scr(mptr);
16095 refresh(rMENU);
16096 break;
16097 //Cancel
16098 case 9:
16099 running = false;
16100 break;
16101 //A,B,C,D
16102 case 14: case 15: case 16: case 17:
16103 data.swap(ret-14);
16104 break;
16105 }
16106 }
16107 while(running);
16108
16109 if(ret==8) //GO
16110 {
16111 int32_t index = *data.loaded;
16112
16113 FlashWarpSquare = -1;
16114 int32_t tm = Map.getCurrMap();
16115 int32_t ts = Map.getCurrScr();
16116 int32_t thistype = mptr->tilewarptype[index];
16117 Map.dowarp(0,index);
16118
16119 if((ts!=Map.getCurrScr() || tm!=Map.getCurrMap()) && thistype != wtCAVE && thistype != wtSCROLL)
16120 {
16121 FlashWarpSquare = (TheMaps[tm*MAPSCRS+ts].warpreturnc>>(index*2))&3;
16122 FlashWarpClk = 32;
16123 }
16124
16125 refresh(rALL);
16126 }
16127
16128 return D_O_K;
16129 }
16130
16131 struct sw_data
16132 {
16133 int swscr[4], swtype[4], swdmap[4], wret[4];
16134 byte oflags;
16135 optional<uint> loaded;
16136
16137 sw_data(mapscr* scr) {load_scr(scr);}
16138 void load_scr(mapscr* scr)
16139 {
16140 oflags = scr->sidewarpoverlayflags;
16141 for(int q = 0; q < 4; ++q)
16142 {
16143 swscr[q] = scr->sidewarpscr[q];
16144 swtype[q] = scr->sidewarptype[q];
16145 swdmap[q] = scr->sidewarpdmap[q];
16146 wret[q] = (scr->warpreturnc >> (2*(q+4)))&3;
16147 }
16148 loaded.reset();
16149
16150 for(int32_t i=0; i<4; i++)
16151 {
16152 sidewarp_dlg[18+i].d2 = 0x80;
16153 if(scr->flags2&(1<<i))
16154 {
16155 sidewarp_dlg[18+i].flags = D_SELECTED ;
16156 sidewarp_dlg[18+i].d2 |= (scr->sidewarpindex>>(2*i))&3;
16157 }
16158 else
16159 {
16160 sidewarp_dlg[18+i].flags = 0;
16161 }
16162 }
16163 }
16164 void save_scr(mapscr* scr)
16165 {
16166 saved=false;
16167 scr->sidewarpoverlayflags = oflags;
16168 scr->warpreturnc = scr->warpreturnc & 0x00FF;
16169 for(int q = 0; q < 4; ++q)
16170 {
16171 scr->sidewarpscr[q] = swscr[q];
16172 scr->sidewarptype[q] = swtype[q];
16173 scr->sidewarpdmap[q] = swdmap[q];
16174 scr->warpreturnc |= wret[q] << (2*(q+4));
16175 }
16176
16177 scr->flags2 &= ~0xF;
16178 scr->sidewarpindex = 0;
16179 for(int32_t i=0; i<4; i++)
16180 {
16181 if(sidewarp_dlg[18+i].flags & D_SELECTED)
16182 scr->flags2 |= 1<<i;
16183 scr->sidewarpindex |= (sidewarp_dlg[18+i].d2&3) << (i*2);
16184 }
16185 }
16186
16187 void load(uint ind)
16188 {
16189 if(ind >= 4) return;
16190 loaded = ind;
16191 sidewarp_dlg[4].d1 = swtype[ind];
16192 sidewarp_dlg[5].d1 = swdmap[ind];
16193 char* buf = (char*)sidewarp_dlg[6].dp;
16194 sprintf(buf,"%02X",swscr[ind]);
16195 sidewarp_dlg[11].d1 = wret[ind];
16196 SETFLAG(sidewarp_dlg[12].flags, D_SELECTED, get_bit(&oflags,ind));
16197 for(int q = 0; q < 4; ++q)
16198 SETFLAG(sidewarp_dlg[14+q].flags,(D_SELECTED|D_DISABLED),q==ind);
16199 }
16200 void save(uint ind)
16201 {
16202 if(ind >= 4) return;
16203 swtype[ind] = sidewarp_dlg[4].d1;
16204 swdmap[ind] = sidewarp_dlg[5].d1;
16205 char* buf = (char*)sidewarp_dlg[6].dp;
16206 swscr[ind] = vbound(zc_xtoi(buf),0x00,0x87);
16207 wret[ind] = sidewarp_dlg[11].d1;
16208 set_bit(&oflags, ind, sidewarp_dlg[12].flags & D_SELECTED);
16209 }
16210 void save()
16211 {
16212 if(loaded)
16213 save(*loaded);
16214 }
16215 void swap(uint ind)
16216 {
16217 if(ind >= 4) return;
16218 if(loaded)
16219 {
16220 save(*loaded);
16221 if(*loaded == ind)
16222 return;
16223 }
16224 load(ind);
16225 }
16226 };
16227 int32_t onSideWarp()
16228 {
16229 restore_mouse();
16230 sidewarp_dlg[0].dp=(void *) "Side Warp";
16231 sidewarp_dlg[0].dp2=get_zc_font(font_lfont);
16232
16233 mapscr* mptr = Map.CurrScr();
16234 char buf[10];
16235 sidewarp_dlg[6].dp=buf;
16236 sidewarp_dlg[13].dp = buf;
16237 sidewarp_dlg[13].dp3 = &sidewarp_dlg[5].d1;
16238
16239 vector<DIALOG*> dlgs;
16240 dlgs.push_back(&sidewarp_dlg[5]);
16241 dlgs.push_back(&sidewarp_dlg[6]);
16242 sidewarp_dlg[13].dp2 = &dlgs;
16243
16244 sw_data data(mptr);
16245 data.load(0);
16246
16247 dmap_list_size=MAXDMAPS;
16248 dmap_list_zero=true;
16249
16250 large_dialog(sidewarp_dlg);
16251
16252 bool running = true;
16253 int ret;
16254 do
16255 {
16256 ret = do_zqdialog(sidewarp_dlg,-1);
16257 switch(ret)
16258 {
16259 // OK, GO
16260 case 7: case 8:
16261 running = false;
16262 data.save();
16263 data.save_scr(mptr);
16264 refresh(rMENU);
16265 break;
16266 //Cancel
16267 case 9:
16268 running = false;
16269 break;
16270 //A,B,C,D
16271 case 14: case 15: case 16: case 17:
16272 data.swap(ret-14);
16273 break;
16274 }
16275 }
16276 while(running);
16277
16278 if(ret==8) //GO
16279 {
16280 int32_t index = *data.loaded;
16281
16282 FlashWarpSquare = -1;
16283 int32_t tm = Map.getCurrMap();
16284 int32_t ts = Map.getCurrScr();
16285
16286 int32_t thistype = mptr->sidewarptype[index];
16287 Map.dowarp(1,index);
16288
16289 if((ts!=Map.getCurrScr() || tm!=Map.getCurrMap()) && thistype != wtSCROLL)
16290 {
16291 FlashWarpSquare = (TheMaps[tm*MAPSCRS+ts].warpreturnc>>(8+index*2))&3;
16292 FlashWarpClk = 0x20;
16293 }
16294
16295 refresh(rALL);
16296 }
16297
16298 return D_O_K;
16299 }
16300
16301
16302
16303 const char *dirlist(int32_t index, int32_t *list_size)
16304 {
16305 if(index>=0)
16306 {
16307 if(index>3)
16308 index=3;
16309
16310 return mazedirstr[index];
16311 }
16312
16313 *list_size=4;
16314 return NULL;
16315 }
16316
16317 12 static ListData path_dlg_list(dirlist, &font);
16318
16319 static const char *wipestr[] = {"None", "Circle", "Oval", "Triangle", "SMAS", "Fade Black"};
16320 // enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
16321 const char *wipelist(int32_t index, int32_t *list_size)
16322 {
16323 if(index>=0)
16324 {
16325 if(index>5)
16326 index=5;
16327
16328 return wipestr[index];
16329 }
16330
16331 *list_size=6;
16332 return NULL;
16333 }
16334
16335 12 static ListData wipe_effect_dlg_list(wipelist, &font);
16336
16337 static DIALOG path_dlg[] =
16338 {
16339 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16340 12 { jwin_win_proc, 80, 57, 161, 182, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Maze Path", NULL, NULL },
16341 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16342 12 { jwin_text_proc, 94, 106, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "1st", NULL, NULL },
16343 12 { jwin_text_proc, 94, 124, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "2nd", NULL, NULL },
16344 12 { jwin_text_proc, 94, 142, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "3rd", NULL, NULL },
16345 12 { jwin_text_proc, 94, 160, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "4th", NULL, NULL },
16346 12 { jwin_text_proc, 94, 178, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Exit", NULL, NULL },
16347 12 { jwin_text_proc, 94, 196, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Wipe effect", NULL, NULL },
16348 12 { jwin_droplist_proc, 140, 102, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
16349 12 { jwin_droplist_proc, 140, 120, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
16350 12 { jwin_droplist_proc, 140, 138, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
16351 12 { jwin_droplist_proc, 140, 156, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
16352 12 { jwin_droplist_proc, 140, 174, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
16353 12 { jwin_droplist_proc, 140, 192, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &wipe_effect_dlg_list, NULL, NULL },
16354 12 { jwin_button_proc, 90, 212, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
16355 12 { jwin_button_proc, 170, 212, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16356 12 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
16357 12 { jwin_text_proc, 87, 82, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "A Lost Woods-style maze screen", NULL, NULL },
16358 12 { jwin_text_proc, 87, 92, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "with a normal and secret exit.", NULL, NULL },
16359 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16360 };
16361
16362 int32_t onPath()
16363 {
16364 restore_mouse();
16365 path_dlg[0].dp2=get_zc_font(font_lfont);
16366
16367 for(int32_t i=0; i<4; i++)
16368 path_dlg[i+8].d1 = Map.CurrScr()->path[i];
16369
16370 path_dlg[12].d1 = Map.CurrScr()->exitdir;
16371 path_dlg[13].d1 = Map.CurrScr()->maze_transition_wipe;
16372
16373 large_dialog(path_dlg);
16374
16375 int32_t ret;
16376
16377 do
16378 {
16379 ret=do_zqdialog(path_dlg,8);
16380
16381 if(ret==14)
16382 {
16383 for(int32_t i=0; i<4; i++)
16384 {
16385 if(path_dlg[i+8].d1 == path_dlg[12].d1)
16386 {
16387 if(jwin_alert("Exit Problem","One of the path's directions is","also the normal Exit direction! Continue?",NULL,"Yes","No",'y','n',get_zc_font(font_lfont))==2)
16388 ret = -1;
16389
16390 break;
16391 }
16392 }
16393 }
16394 }
16395 while(ret == -1);
16396
16397 if(ret==14)
16398 {
16399 saved=false;
16400
16401 for(int32_t i=0; i<4; i++)
16402 Map.CurrScr()->path[i] = path_dlg[i+8].d1;
16403
16404 Map.CurrScr()->exitdir = path_dlg[12].d1;
16405 Map.CurrScr()->maze_transition_wipe = path_dlg[13].d1;
16406
16407 if(!(Map.CurrScr()->flags&fMAZE))
16408 if(jwin_alert("Screen Flag","Turn on the 'Use Maze Path' Screen Flag?","(Go to 'Screen Data' to turn it off.)",NULL,"Yes","No",'y','n',get_zc_font(font_lfont))==1)
16409 Map.CurrScr()->flags |= fMAZE;
16410 }
16411
16412 refresh(rMAP+rMENU);
16413 return D_O_K;
16414 }
16415
16416
16417
16418 static DIALOG editinfo_dlg[] =
16419 {
16420 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
16421 12 { jwin_win_proc, 0, 10, 208, 204, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
16422 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16423 12 { jwin_text_proc, 24, 60, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "1st", NULL, NULL },
16424 12 { jwin_text_proc, 24, 106, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "2nd", NULL, NULL },
16425 12 { jwin_text_proc, 24, 152, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "3rd", NULL, NULL },
16426 12 { jwin_text_proc, 56, 60, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
16427 12 { jwin_text_proc, 56, 106, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
16428 12 { jwin_text_proc, 56, 152, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
16429 // 8
16430 12 { jwin_edit_proc, 86, 56, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16431 12 { d_ndroplist_proc, 56, 74, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16432 12 { jwin_edit_proc, 86, 102, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16433 12 { d_ndroplist_proc, 56, 120, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16434 12 { jwin_edit_proc, 86, 148, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16435 12 { d_ndroplist_proc, 56, 166, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16436 12 { jwin_text_proc, 24, 42, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
16437 12 { jwin_edit_proc, 56, 38, 137, 16, vc(12), vc(1), 0, 0, 31, 0, NULL, NULL, NULL },
16438 // 16
16439 12 { jwin_button_proc, 34, 188, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
16440 12 { jwin_button_proc, 114, 188, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16441 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16442 };
16443
16444 void EditInfoType(int32_t index)
16445 {
16446 char ps1[6],ps2[6],ps3[6];
16447 char infoname[33];
16448 char caption[40];
16449
16450 int32_t str1, str2, str3;
16451
16452 sprintf(caption,"Info Data %d",index);
16453 editinfo_dlg[0].dp = caption;
16454 editinfo_dlg[0].dp2 = get_zc_font(font_lfont);
16455
16456 sprintf(ps1,"%d",QMisc.info[index].price[0]);
16457 sprintf(ps2,"%d",QMisc.info[index].price[1]);
16458 sprintf(ps3,"%d",QMisc.info[index].price[2]);
16459 strncpy(infoname,QMisc.info[index].name,32);
16460 infoname[32] = 0;
16461 editinfo_dlg[8].dp = ps1;
16462 editinfo_dlg[10].dp = ps2;
16463 editinfo_dlg[12].dp = ps3;
16464 editinfo_dlg[15].dp = infoname;
16465 str1 = QMisc.info[index].str[0];
16466 str2 = QMisc.info[index].str[1];
16467 str3 = QMisc.info[index].str[2];
16468 editinfo_dlg[9].d1 = MsgStrings[str1].listpos;
16469 editinfo_dlg[11].d1 = MsgStrings[str2].listpos;
16470 editinfo_dlg[13].d1 = MsgStrings[str3].listpos;
16471 ListData msgs_list(msgslist2, &a4fonts[font_lfont_l]);
16472 editinfo_dlg[9].dp =
16473 editinfo_dlg[11].dp =
16474 editinfo_dlg[13].dp = (void *) &msgs_list;
16475
16476 large_dialog(editinfo_dlg);
16477
16478 int32_t ret = do_zqdialog(editinfo_dlg,-1);
16479
16480 if(ret==16)
16481 {
16482 saved=false;
16483 QMisc.info[index].price[0] = vbound(atoi(ps1), 0, 65535);
16484 QMisc.info[index].price[1] = vbound(atoi(ps2), 0, 65535);
16485 QMisc.info[index].price[2] = vbound(atoi(ps3), 0, 65535);
16486 strncpy(QMisc.info[index].name,infoname,32);
16487 str1 = editinfo_dlg[9].d1;
16488 str2 = editinfo_dlg[11].d1;
16489 str3 = editinfo_dlg[13].d1;
16490 QMisc.info[index].str[0] = msg_at_pos(str1);
16491 QMisc.info[index].str[1] = msg_at_pos(str2);
16492 QMisc.info[index].str[2] = msg_at_pos(str3);
16493
16494 //move 0s to the end
16495 word swaptmp;
16496
16497 if(QMisc.info[index].str[0] == 0)
16498 {
16499 //possibly permute the infos
16500 if(QMisc.info[index].str[1] != 0)
16501 {
16502 //swap
16503 swaptmp = QMisc.info[index].str[0];
16504 QMisc.info[index].str[0] = QMisc.info[index].str[1];
16505 QMisc.info[index].str[1] = swaptmp;
16506 swaptmp = QMisc.info[index].price[0];
16507 QMisc.info[index].price[0] = QMisc.info[index].price[1];
16508 QMisc.info[index].price[1] = swaptmp;
16509 }
16510 else if(QMisc.info[index].str[2] != 0)
16511 {
16512 //move info 0 to 1, 1 to 2, and 2 to 0
16513 swaptmp = QMisc.info[index].str[0];
16514 QMisc.info[index].str[0] = QMisc.info[index].str[2];
16515 QMisc.info[index].str[2] = QMisc.info[index].str[1];
16516 QMisc.info[index].str[1] = swaptmp;
16517 swaptmp = QMisc.info[index].price[0];
16518 QMisc.info[index].price[0] = QMisc.info[index].price[2];
16519 QMisc.info[index].price[2] = QMisc.info[index].price[1];
16520 QMisc.info[index].price[1] = swaptmp;
16521 }
16522 }
16523
16524 if(QMisc.info[index].str[1] == 0 && QMisc.info[index].str[2] != 0)
16525 //swap
16526 {
16527 swaptmp = QMisc.info[index].str[1];
16528 QMisc.info[index].str[1] = QMisc.info[index].str[2];
16529 QMisc.info[index].str[2] = swaptmp;
16530 swaptmp = QMisc.info[index].price[1];
16531 QMisc.info[index].price[1] = QMisc.info[index].price[2];
16532 QMisc.info[index].price[2] = swaptmp;
16533 }
16534 }
16535 }
16536
16537 int32_t onInfoTypes()
16538 {
16539 info_list_size = 256;
16540
16541 int32_t index = select_data("Info Types",0,infolist,"Edit","Done",get_zc_font(font_lfont));
16542
16543 while(index!=-1)
16544 {
16545 EditInfoType(index);
16546
16547 index = select_data("Info Types",index,infolist,"Edit","Done",get_zc_font(font_lfont));
16548 }
16549
16550 return D_O_K;
16551 }
16552
16553
16554
16555 //This dialogie is self-contained, and does not use dialogue control numbers in a separate array to generate its fields.
16556 static DIALOG editshop_dlg[] =
16557 {
16558 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
16559 12 { jwin_win_proc, 0, 10, 221, 204, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
16560 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16561 12 { jwin_text_proc, 24, 60, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "1st", NULL, NULL },
16562 12 { jwin_text_proc, 24, 106, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "2nd", NULL, NULL },
16563 12 { jwin_text_proc, 24, 152, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "3rd", NULL, NULL },
16564 12 { jwin_text_proc, 56, 60, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
16565 12 { jwin_text_proc, 56, 106, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
16566 12 { jwin_text_proc, 56, 152, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
16567 // 8
16568 12 { jwin_edit_proc, 86, 56, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16569 12 { d_nidroplist_proc, 56, 74, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16570 12 { jwin_edit_proc, 86, 102, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16571 12 { d_nidroplist_proc, 56, 120, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16572 12 { jwin_edit_proc, 86, 148, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16573 12 { d_nidroplist_proc, 56, 166, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16574 12 { jwin_text_proc, 24, 42, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
16575 12 { jwin_edit_proc, 56, 38, 137, 16, vc(12), vc(1), 0, 0, 31, 0, NULL, NULL, NULL },
16576
16577 // 16
16578 12 { jwin_button_proc, 40, 188, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
16579 12 { jwin_button_proc, 121, 188, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16580 //18
16581 12 { jwin_text_proc, 130, 60, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Info:", NULL, NULL },
16582 12 { jwin_text_proc, 130, 106, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Info:", NULL, NULL },
16583 12 { jwin_text_proc, 130, 152, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Info:", NULL, NULL },
16584 // 21
16585 12 { jwin_edit_proc, 155, 56, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16586 12 { jwin_edit_proc, 155, 102, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16587 12 { jwin_edit_proc, 155, 148, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16588
16589 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16590 };
16591
16592 void EditShopType(int32_t index)
16593 {
16594
16595 build_bii_list(true);
16596 char ps1[6],ps2[6],ps3[6];
16597 char info1[6],info2[6],info3[6];
16598 char shopname[32];
16599 char caption[40];
16600
16601 sprintf(caption,"Shop Data %d",index);
16602 editshop_dlg[0].dp = caption;
16603 editshop_dlg[0].dp2=get_zc_font(font_lfont);
16604
16605 sprintf(ps1,"%d",QMisc.shop[index].price[0]);
16606 sprintf(ps2,"%d",QMisc.shop[index].price[1]);
16607 sprintf(ps3,"%d",QMisc.shop[index].price[2]);
16608
16609 sprintf(info1,"%d",QMisc.shop[index].str[0]);
16610 sprintf(info2,"%d",QMisc.shop[index].str[1]);
16611 sprintf(info3,"%d",QMisc.shop[index].str[2]);
16612
16613 sprintf(shopname,"%s",QMisc.shop[index].name);
16614 editshop_dlg[8].dp = ps1;
16615 editshop_dlg[10].dp = ps2;
16616 editshop_dlg[12].dp = ps3;
16617 editshop_dlg[15].dp = shopname;
16618
16619 editshop_dlg[21].dp = info1;
16620 editshop_dlg[22].dp = info2;
16621 editshop_dlg[23].dp = info3;
16622
16623 ListData item_list(itemlist_num, &a4fonts[font_lfont_l]);
16624
16625 editshop_dlg[9].dp = (void *) &item_list;
16626 editshop_dlg[11].dp = (void *) &item_list;
16627 editshop_dlg[13].dp = (void *) &item_list;
16628
16629 for(int32_t i=0; i<3; ++i)
16630 {
16631 if(QMisc.shop[index].hasitem[i])
16632 {
16633 for(int32_t j=0; j<bii_cnt; j++)
16634 {
16635 if(bii[j].i == QMisc.shop[index].item[i])
16636 {
16637 editshop_dlg[9+(i<<1)].d1 = j;
16638 }
16639 }
16640 }
16641 else
16642 {
16643 editshop_dlg[9+(i<<1)].d1 = -2;
16644 }
16645 }
16646
16647 large_dialog(editshop_dlg);
16648
16649 int32_t ret = do_zqdialog(editshop_dlg,-1);
16650
16651 if(ret==16)
16652 {
16653 saved=false;
16654 QMisc.shop[index].price[0] = vbound(atoi(ps1), 0, 65535);
16655 QMisc.shop[index].price[1] = vbound(atoi(ps2), 0, 65535);
16656 QMisc.shop[index].price[2] = vbound(atoi(ps3), 0, 65535);
16657
16658 QMisc.shop[index].str[0] = vbound(atoi(info1), 0, 65535);
16659 QMisc.shop[index].str[1] = vbound(atoi(info2), 0, 65535);
16660 QMisc.shop[index].str[2] = vbound(atoi(info3), 0, 65535);
16661
16662 snprintf(QMisc.shop[index].name, 32, "%s",shopname);
16663
16664 for(int32_t i=0; i<3; ++i)
16665 {
16666 if(bii[editshop_dlg[9+(i<<1)].d1].i == -2)
16667 {
16668 QMisc.shop[index].hasitem[i] = 0;
16669 QMisc.shop[index].item[i] = 0;
16670 QMisc.shop[index].price[i] = 0;
16671 }
16672 else
16673 {
16674 QMisc.shop[index].hasitem[i] = 1;
16675 QMisc.shop[index].item[i] = bii[editshop_dlg[9+(i<<1)].d1].i;
16676 }
16677 }
16678
16679 //filter all the 0 items to the end (yeah, bubble sort; sue me)
16680 word swaptmp;
16681
16682 for(int32_t j=0; j<3-1; j++)
16683 {
16684 for(int32_t k=0; k<2-j; k++)
16685 {
16686 if(QMisc.shop[index].hasitem[k]==0)
16687 {
16688 swaptmp = QMisc.shop[index].item[k];
16689 QMisc.shop[index].item[k] = QMisc.shop[index].item[k+1];
16690 QMisc.shop[index].item[k+1] = swaptmp;
16691 swaptmp = QMisc.shop[index].price[k];
16692 QMisc.shop[index].price[k] = QMisc.shop[index].price[k+1];
16693 QMisc.shop[index].price[k+1] = swaptmp;
16694 swaptmp = QMisc.shop[index].hasitem[k];
16695 QMisc.shop[index].hasitem[k] = QMisc.shop[index].item[k+1];
16696 QMisc.shop[index].hasitem[k+1] = swaptmp;
16697 }
16698 }
16699 }
16700 }
16701 }
16702
16703 int32_t onShopTypes()
16704 {
16705 shop_list_size = 256;
16706
16707 int32_t index = select_data("Shop Types",0,shoplist,"Edit","Done",get_zc_font(font_lfont));
16708
16709 while(index!=-1)
16710 {
16711 EditShopType(index);
16712 index = select_data("Shop Types",index,shoplist,"Edit","Done",get_zc_font(font_lfont));
16713 }
16714
16715 return D_O_K;
16716 }
16717
16718 void call_bottle_dlg(int32_t index);
16719 int32_t onBottleTypes()
16720 {
16721 bottle_list_size = 64;
16722 int32_t index = 0;
16723
16724 while(index > -1)
16725 {
16726 index = select_data("Bottle Types", index, bottlelist, "Edit", "Done", get_zc_font(font_lfont));
16727 if(index > -1)
16728 call_bottle_dlg(index);
16729 }
16730
16731 return D_O_K;
16732 }
16733
16734 void call_bottleshop_dlg(int32_t index);
16735 int32_t onBottleShopTypes()
16736 {
16737 bottleshop_list_size = 256;
16738 int32_t index = 0;
16739
16740 while(index > -1)
16741 {
16742 index = select_data("Bottle Shop Types", index, bottleshoplist, "Edit", "Done", get_zc_font(font_lfont));
16743 if(index > -1)
16744 call_bottleshop_dlg(index);
16745 }
16746
16747 return D_O_K;
16748 }
16749
16750
16751 static char item_drop_set_str_buf[70];
16752 int32_t item_drop_set_list_size=MAXITEMDROPSETS;
16753
16754 const char *itemdropsetlist(int32_t index, int32_t *list_size)
16755 {
16756 if(index>=0)
16757 {
16758 bound(index,0,item_drop_set_list_size-1);
16759 sprintf(item_drop_set_str_buf,"%3d: %s",index,item_drop_sets[index].name);
16760 return item_drop_set_str_buf;
16761 }
16762
16763 *list_size=item_drop_set_list_size;
16764 return NULL;
16765 }
16766
16767 int32_t d_itemdropedit_proc(int32_t msg,DIALOG *d,int32_t c);
16768
16769 static int32_t edititemdropset_1_list[] =
16770 {
16771 // dialog control number
16772 10, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,24,25,26,27,28, -1
16773 };
16774
16775 static int32_t edititemdropset_2_list[] =
16776 {
16777 // dialog control number
16778 12, 13, 29, 30, 31, 32, 33,34,35,36,37,38,39,40,41,42,43, -1
16779 };
16780
16781 static TABPANEL edititemdropset_tabs[] =
16782 {
16783 // (text)
16784 { (char *)" Page 1 ", D_SELECTED, edititemdropset_1_list, 0, NULL },
16785 { (char *)" Page 2 ", 0, edititemdropset_2_list, 0, NULL },
16786 { NULL, 0, NULL, 0, NULL }
16787 };
16788
16789 static DIALOG edititemdropset_dlg[] =
16790 {
16791 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
16792 12 { jwin_win_proc, 0, 0, 320, 240, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
16793 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16794
16795 // 2
16796 12 { jwin_button_proc, 89, 213, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
16797 12 { jwin_button_proc, 169, 213, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16798
16799 // 4
16800 12 { jwin_text_proc, 9, 29, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
16801 12 { jwin_edit_proc, 39, 25, 275, 16, vc(12), vc(1), 0, 0, 32, 0, NULL, NULL, NULL },
16802 12 { jwin_text_proc, 9, 47, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Nothing Chance:", NULL, NULL },
16803 12 { d_itemdropedit_proc, 84, 43, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16804
16805 12 { jwin_tab_proc, 4, 65, 312, 143, vc(0), vc(15), 0, 0, 0, 0, (void *) edititemdropset_tabs, NULL, (void *)edititemdropset_dlg },
16806 12 { jwin_text_proc, 114, 43+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16807 // 10
16808 12 { jwin_text_proc, 10, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Chance:", NULL, NULL },
16809 12 { jwin_text_proc, 56, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Item:", NULL, NULL },
16810 12 { jwin_text_proc, 10, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Chance:", NULL, NULL },
16811 12 { jwin_text_proc, 56, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Item:", NULL, NULL },
16812
16813 // 14
16814 12 { d_itemdropedit_proc, 9, 96, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16815 12 { d_idroplist_proc, 55, 96, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16816 12 { jwin_text_proc, 37, 96+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16817 12 { d_itemdropedit_proc, 9, 118, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16818 12 { d_idroplist_proc, 55, 118, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16819 12 { jwin_text_proc, 37, 118+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16820 12 { d_itemdropedit_proc, 9, 140, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16821 12 { d_idroplist_proc, 55, 140, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16822 12 { jwin_text_proc, 37, 140+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16823 12 { d_itemdropedit_proc, 9, 162, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16824 12 { d_idroplist_proc, 55, 162, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16825 12 { jwin_text_proc, 37, 162+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16826 12 { d_itemdropedit_proc, 9, 184, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16827 12 { d_idroplist_proc, 55, 184, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16828 12 { jwin_text_proc, 37, 184+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16829 // 29
16830 12 { d_itemdropedit_proc, 9, 96, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16831 12 { d_idroplist_proc, 55, 96, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16832 12 { jwin_text_proc, 37, 96+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16833 12 { d_itemdropedit_proc, 9, 118, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16834 12 { d_idroplist_proc, 55, 118, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16835 12 { jwin_text_proc, 37, 118+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16836 12 { d_itemdropedit_proc, 9, 140, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16837 12 { d_idroplist_proc, 55, 140, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16838 12 { jwin_text_proc, 37, 140+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16839 12 { d_itemdropedit_proc, 9, 162, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16840 12 { d_idroplist_proc, 55, 162, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16841 12 { jwin_text_proc, 37, 162+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16842 12 { d_itemdropedit_proc, 9, 184, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16843 12 { d_idroplist_proc, 55, 184, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16844 12 { jwin_text_proc, 39, 184+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16845 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16846 };
16847
16848 int32_t d_itemdropedit_proc(int32_t msg,DIALOG *d,int32_t c)
16849 {
16850 int32_t ret = jwin_edit_proc(msg,d,c);
16851
16852 if(msg==MSG_DRAW)
16853 {
16854 int32_t t = atoi((char*)edititemdropset_dlg[7].dp);
16855
16856 for(int32_t i=0; i<10; ++i)
16857 {
16858 t += atoi((char*)edititemdropset_dlg[14+(i*3)].dp);
16859 }
16860
16861 {
16862 int32_t t2 = (int32_t)(100*atoi((char*)edititemdropset_dlg[7].dp) / zc_max(t,1));
16863 sprintf((char*)edititemdropset_dlg[9].dp,"%d%%%s",t2, t2 <= 11 ? " ":"");
16864 object_message(&edititemdropset_dlg[9],MSG_DRAW,c);
16865 }
16866
16867 for(int32_t i=0; i<10; ++i)
16868 {
16869 int32_t t2 = (int32_t)(100*atoi((char*)edititemdropset_dlg[14+(i*3)].dp) / zc_max(t,1));
16870 sprintf((char*)edititemdropset_dlg[16+(i*3)].dp,"%d%%%s",t2, t2 <= 11 ? " ":"");
16871 object_message(&edititemdropset_dlg[16+(i*3)],MSG_DRAW,c);
16872 }
16873
16874 }
16875
16876 return ret;
16877 }
16878
16879 void EditItemDropSet(int32_t index)
16880 {
16881 build_bii_list(true);
16882 char chance[11][10];
16883 char itemdropsetname[64];
16884 char caption[40];
16885 char percent_str[11][5];
16886
16887 sprintf(caption,"Item Drop Set Data %d",index);
16888 edititemdropset_dlg[0].dp = caption;
16889 edititemdropset_dlg[0].dp2=get_zc_font(font_lfont);
16890
16891 sprintf(itemdropsetname,"%s",item_drop_sets[index].name);
16892 edititemdropset_dlg[5].dp = itemdropsetname;
16893
16894 sprintf(chance[0],"%d",item_drop_sets[index].chance[0]);
16895 edititemdropset_dlg[7].dp = chance[0];
16896
16897 ListData item_list(itemlist_num, &a4fonts[font_lfont_l]);
16898 sprintf(percent_str[0]," ");
16899 edititemdropset_dlg[9].dp = percent_str[0];
16900
16901 for(int32_t i=0; i<10; ++i)
16902 {
16903 sprintf(chance[i+1],"%d",item_drop_sets[index].chance[i+1]);
16904 edititemdropset_dlg[14+(i*3)].dp = chance[i+1];
16905 edititemdropset_dlg[15+(i*3)].dp = (void *) &item_list;
16906 sprintf(percent_str[i+1]," ");
16907 edititemdropset_dlg[16+(i*3)].dp = percent_str[i+1];
16908
16909 if(item_drop_sets[index].chance[i+1]==0)
16910 {
16911 edititemdropset_dlg[15+(i*3)].d1 = -2;
16912 }
16913 else
16914 {
16915 for(int32_t j=0; j<bii_cnt; j++)
16916 {
16917 if(bii[j].i == item_drop_sets[index].item[i])
16918 {
16919 edititemdropset_dlg[15+(i*3)].d1 = j;
16920 }
16921 }
16922 }
16923 }
16924
16925 large_dialog(edititemdropset_dlg);
16926
16927 int32_t ret = do_zqdialog(edititemdropset_dlg,-1);
16928
16929 if(ret==2)
16930 {
16931 saved=false;
16932
16933 sprintf(item_drop_sets[index].name,"%s",itemdropsetname);
16934
16935 item_drop_sets[index].chance[0]=atoi(chance[0]);
16936
16937 for(int32_t i=0; i<10; ++i)
16938 {
16939 item_drop_sets[index].chance[i+1]=atoi(chance[i+1]);
16940
16941 if(bii[edititemdropset_dlg[15+(i*3)].d1].i == -2)
16942 {
16943 item_drop_sets[index].chance[i+1]=0;
16944 }
16945 else
16946 {
16947 item_drop_sets[index].item[i] = bii[edititemdropset_dlg[15+(i*3)].d1].i;
16948 }
16949
16950 if(item_drop_sets[index].chance[i+1]==0)
16951 {
16952 item_drop_sets[index].item[i] = 0;
16953 }
16954 }
16955 }
16956 }
16957
16958 9 int32_t count_item_drop_sets()
16959 {
16960 9 int32_t count=0;
16961 9 bool found=false;
16962
16963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 for(count=255; (count>0); --count)
16964 {
16965
2/2
✓ Branch 0 taken 2186 times.
✓ Branch 1 taken 24056 times.
26242 for(int32_t i=0; (i<11); ++i)
16966 {
16967
2/2
✓ Branch 0 taken 24047 times.
✓ Branch 1 taken 9 times.
24056 if(item_drop_sets[count].chance[i]!=0)
16968 {
16969 9 found=true;
16970 9 break;
16971 }
16972 24047 }
16973
16974
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2186 times.
2195 if(found)
16975 {
16976 9 break;
16977 }
16978 2186 }
16979
16980 9 return count+1;
16981 }
16982
16983 int32_t onItemDropSets()
16984 {
16985 item_drop_set_list_size = MAXITEMDROPSETS;
16986
16987 int32_t index = select_data("Item Drop Sets",0,itemdropsetlist,"Edit","Done",get_zc_font(font_lfont));
16988
16989 while(index!=-1)
16990 {
16991 EditItemDropSet(index);
16992 index = select_data("Item Drop Sets",index,itemdropsetlist,"Edit","Done",get_zc_font(font_lfont));
16993 }
16994
16995 return D_O_K;
16996 }
16997
16998 int32_t curr_ring = 0;
16999
17000 void EditWarpRingScr(int32_t ring,int32_t index)
17001 {
17002 char caption[40],buf[10];
17003 restore_mouse();
17004
17005 sprintf(caption,"Ring %d Warp %d",ring,index+1);
17006 warpring_warp_dlg[0].dp = (void *)caption;
17007 warpring_warp_dlg[0].dp2=get_zc_font(font_lfont);
17008
17009 sprintf(buf,"%02X",QMisc.warp[ring].scr[index]);
17010 warpring_warp_dlg[3].d1 = QMisc.warp[ring].dmap[index];
17011 warpring_warp_dlg[4].dp = buf;
17012 warpring_warp_dlg[8].dp = buf;
17013 warpring_warp_dlg[8].dp3 = &warpring_warp_dlg[3].d1;
17014
17015 vector<DIALOG*> dlgs;
17016 dlgs.push_back(&warpring_warp_dlg[3]);
17017 dlgs.push_back(&warpring_warp_dlg[4]);
17018 warpring_warp_dlg[8].dp2 = &dlgs;
17019
17020 dmap_list_size=MAXDMAPS;
17021 dmap_list_zero=true;
17022
17023 large_dialog(warpring_warp_dlg);
17024
17025 int32_t ret=do_zqdialog(warpring_warp_dlg,-1);
17026
17027 if(ret==5 || ret==6)
17028 {
17029 saved=false;
17030 QMisc.warp[ring].dmap[index] = warpring_warp_dlg[3].d1;
17031 QMisc.warp[ring].scr[index] = zc_xtoi(buf);
17032 }
17033
17034 if(ret==6)
17035 {
17036 Map.dowarp2(ring,index);
17037 refresh(rALL);
17038 }
17039 }
17040
17041 int32_t d_warplist_proc(int32_t msg,DIALOG *d,int32_t c)
17042 {
17043 if(msg==MSG_DRAW)
17044 {
17045 int32_t *xy = (int32_t*)(d->dp3);
17046 int32_t ring = curr_ring;
17047 int32_t dmap = QMisc.warp[ring].dmap[d->d1];
17048 float temp_scale = 1.5;
17049
17050 drawdmap(dmap);
17051
17052 if(xy[0]||xy[1])
17053 {
17054 int32_t x = d->x+int32_t((xy[0]-2)*temp_scale);
17055 int32_t y = d->y+int32_t((xy[1]-2)*temp_scale);
17056 int32_t w = 84;
17057 int32_t h = 52;
17058 jwin_draw_frame(screen,x,y,w,h,FR_DEEP);
17059 drawdmap_screen(x+2,y+2,w-4,h-4,dmap);
17060 }
17061
17062 if(xy[2]||xy[3])
17063 {
17064 textprintf_ex(screen,font,d->x+int32_t(xy[2]*temp_scale),d->y+int32_t(xy[3]*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Map: %d ",DMaps[dmap].map+1);
17065 }
17066
17067 if(xy[4]||xy[5])
17068 {
17069 textprintf_ex(screen,font,d->x+int32_t(xy[4]*temp_scale),d->y+int32_t(xy[5]*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Level:%2d ",DMaps[dmap].level);
17070 }
17071
17072 if(xy[6]||xy[7])
17073 {
17074 textprintf_ex(screen,font,d->x+int32_t(xy[6]*temp_scale),d->y+int32_t(xy[7]*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Scr: 0x%02X ",QMisc.warp[ring].scr[d->d1]);
17075 }
17076 }
17077
17078 return jwin_list_proc(msg,d,c);
17079 }
17080
17081 int32_t d_wclist_proc(int32_t msg,DIALOG *d,int32_t c)
17082 {
17083 int32_t d1 = d->d1;
17084 int32_t ret = jwin_droplist_proc(msg,d,c);
17085 QMisc.warp[curr_ring].size=d->d1+3;
17086
17087 if(d->d1 != d1)
17088 return D_CLOSE;
17089
17090 return ret;
17091 }
17092
17093 const char *wclist(int32_t index, int32_t *list_size)
17094 {
17095 static char buf[2];
17096
17097 if(index>=0)
17098 {
17099 if(index>6)
17100 index=6;
17101
17102 sprintf(buf,"%d",index+3);
17103 return buf;
17104 }
17105
17106 *list_size=7;
17107 return NULL;
17108 }
17109
17110 //int32_t warpringdmapxy[8] = {160,116,160,90,160,102,160,154};
17111 int32_t warpringdmapxy[8] = {80,26,80,0,80,12,80,78};
17112
17113 12 static ListData number_list(numberlist, &font);
17114 12 static ListData wc_list(wclist, &font);
17115
17116 static DIALOG warpring_dlg[] =
17117 {
17118 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
17119 12 { jwin_win_proc, 0, 0, 193, 166, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
17120 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17121 12 { jwin_text_proc, 16, 33, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Count:", NULL, NULL },
17122 12 { d_wclist_proc, 72, 29, 48, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 1, 0, (void *) &wc_list, NULL, NULL },
17123 // 4
17124 12 { d_warplist_proc, 16, 50, 65, 71, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &number_list, NULL, warpringdmapxy },
17125 12 { jwin_button_proc, 26, 140, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
17126 12 { jwin_button_proc, 106, 140, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
17127 12 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
17128 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17129 };
17130
17131 int32_t select_warp()
17132 {
17133 QMisc.warp[curr_ring].size = vbound(QMisc.warp[curr_ring].size,3,9);
17134 number_list_zero = false;
17135
17136 int32_t ret=4;
17137
17138 large_dialog(warpring_dlg);
17139
17140 do
17141 {
17142 number_list_size = QMisc.warp[curr_ring].size;
17143 warpring_dlg[3].d1 = QMisc.warp[curr_ring].size-3;
17144 ret = do_zqdialog(warpring_dlg,ret);
17145 }
17146 while(ret==3);
17147
17148 if(ret==6 || ret==0)
17149 {
17150 return -1;
17151 }
17152
17153 return warpring_dlg[4].d1;
17154 }
17155
17156 void EditWarpRing(int32_t ring)
17157 {
17158 char buf[40];
17159 sprintf(buf,"Ring %d Warps",ring);
17160 warpring_dlg[0].dp = buf;
17161 warpring_dlg[0].dp2 = get_zc_font(font_lfont);
17162 curr_ring = ring;
17163
17164 int32_t index = select_warp();
17165
17166 while(index!=-1)
17167 {
17168 EditWarpRingScr(ring,index);
17169 index = select_warp();
17170 }
17171 }
17172
17173 int32_t onWarpRings()
17174 {
17175 number_list_size = 9;
17176 number_list_zero = true;
17177
17178 int32_t index = select_data("Warp Rings",0,numberlist,"Edit","Done",get_zc_font(font_lfont));
17179
17180 while(index!=-1)
17181 {
17182 EditWarpRing(index);
17183 number_list_size = 9;
17184 number_list_zero = true;
17185 index = select_data("Warp Rings",index,numberlist,"Edit","Done",get_zc_font(font_lfont));
17186 }
17187
17188 return D_O_K;
17189 }
17190
17191 const char *enemy_viewer(int32_t index, int32_t *list_size)
17192 {
17193 if(index<0)
17194 {
17195 *list_size=10;
17196
17197 return NULL;
17198 }
17199
17200 int32_t guy=Map.CurrScr()->enemy[index];
17201
17202 if (guy == 0) return "(None)";
17203 return guy>=eSTART ? guy_string[guy] : (char *) "(Guy - Do Not Use!)";
17204 }
17205
17206 enemy_struct bie[eMAXGUYS];
17207 enemy_struct ce[100];
17208 int32_t enemy_type=0,bie_cnt=-1,ce_cnt;
17209
17210 enemy_struct big[zqMAXGUYS];
17211 enemy_struct cg[100];
17212 int32_t guy_type=0,big_cnt=-1,cg_cnt;
17213
17214 //Uses old_max_guys[] in zq_misc.cpp to define what are visible if bool hide is set true. -Z
17215 void build_bie_list(bool hide)
17216 {
17217 bie[0].s = (char *)"(None)";
17218 bie[0].i = 0;
17219 bie_cnt=1;
17220
17221 for(int32_t i=1; i<eMAXGUYS; i++)
17222 {
17223 if (i < eSTART) continue; // ignore guys - enemies only!
17224
17225 if(i >= OLDMAXGUYS || old_guy_string[i][strlen(old_guy_string[i])-1]!=' ' || !hide)
17226 {
17227 bie[bie_cnt].s = (char *)guy_string[i];
17228 bie[bie_cnt].i = i;
17229 ++bie_cnt;
17230 }
17231 }
17232
17233 for(int32_t i=1; i<bie_cnt-1; i++) //Start at 1 so '(None)' isn't alphabetized!
17234 {
17235 for(int32_t j=i+1; j<bie_cnt; j++)
17236 {
17237 if(strcmp(bie[i].s,bie[j].s)>0)
17238 {
17239 zc_swap(bie[i],bie[j]);
17240 }
17241 }
17242 }
17243 }
17244
17245 int32_t efrontfacingtile(int32_t id)
17246 {
17247 int32_t anim = get_qr(qr_NEWENEMYTILES)?guysbuf[id].e_anim:guysbuf[id].anim;
17248 int32_t usetile = 0;
17249
17250 switch(anim)
17251 {
17252
17253 case aNONE: break;
17254 case aAQUA:
17255 if(!(get_qr(qr_NEWENEMYTILES) && guysbuf[id].attributes[0]))
17256 break;
17257
17258 case aWALLM:
17259 case aGHOMA:
17260 usetile=1;
17261 break;
17262
17263 //Fallthrough
17264 case a2FRM4DIR:
17265 case aWALK:
17266 usetile=2;
17267 break;
17268
17269 case aLEV:
17270 case a3FRM4DIR:
17271 usetile=3;
17272 break;
17273
17274 case aLANM:
17275 usetile = !(get_qr(qr_NEWENEMYTILES))?0:4;
17276 break;
17277
17278 case aNEWDONGO:
17279 case a4FRM8EYE:
17280 case aNEWWIZZ:
17281 case aARMOS4:
17282 case aNEWTEK:
17283 case aNEWWALLM:
17284 case a4FRM4DIRF:
17285 case a4FRM4DIR:
17286 case a4FRM8DIRF:
17287 case a4FRMPOS8DIR:
17288 case a4FRMPOS8DIRF:
17289 case a4FRMPOS4DIR:
17290 case a4FRMPOS4DIRF:
17291 usetile=4;
17292 break;
17293
17294 case aDONGO:
17295 usetile=6;
17296 break;
17297
17298 case aDONGOBS:
17299 usetile=24;
17300 break;
17301
17302 case aNEWLEV:
17303 usetile=40;
17304 break;
17305
17306 case aNEWZORA:
17307 if(guysbuf[id].family==eeZORA)
17308 usetile=44;
17309
17310 break;
17311
17312 case aGLEEOK:
17313 if(!get_qr(qr_NEWENEMYTILES))
17314 usetile = (guysbuf[id].s_tile - guysbuf[id].tile)+1;
17315 else
17316 usetile = (guysbuf[id].attributes[7]);
17317
17318 break;
17319 }
17320
17321 return zc_max(get_qr(qr_NEWENEMYTILES) ? -guysbuf[id].e_tile
17322 : -guysbuf[id].tile, usetile);
17323 }
17324
17325 int32_t onEnemies()
17326 {
17327 call_screenenemies_dialog();
17328 refresh(rALL);
17329 return D_O_K;
17330 }
17331
17332 char author[65],title[65],password[32];
17333
17334 int32_t d_showedit_proc(int32_t msg,DIALOG *d,int32_t c)
17335 {
17336 int32_t ret = jwin_edit_proc(msg,d,c);
17337
17338 if(msg==MSG_DRAW)
17339 {
17340 (d+1)->proc(MSG_DRAW,d+1,0);
17341 }
17342
17343 return ret;
17344 }
17345
17346 int32_t onHeader()
17347 {
17348 call_header_dlg();
17349 return D_O_K;
17350 }
17351
17352 void call_cheats_dlg();
17353 int32_t onCheats()
17354 {
17355 call_cheats_dlg();
17356 return D_O_K;
17357 }
17358
17359 bool do_x_button(BITMAP *dest, int32_t x, int32_t y)
17360 {
17361 bool over=false;
17362
17363 while(gui_mouse_b())
17364 {
17365 custom_vsync();
17366
17367 if(isinRect(gui_mouse_x(),gui_mouse_y(),x,y,x+15,y+13))
17368 {
17369 if(!over)
17370 {
17371 draw_x_button(dest, x, y, D_SELECTED);
17372 over=true;
17373 }
17374 }
17375 else
17376 {
17377 if(over)
17378 {
17379 draw_x_button(dest, x, y, 0);
17380 over=false;
17381 }
17382 }
17383 }
17384
17385 return over;
17386 }
17387
17388 bool do_question_button(BITMAP *dest, int32_t x, int32_t y)
17389 {
17390 bool over=false;
17391
17392 while(gui_mouse_b())
17393 {
17394 custom_vsync();
17395
17396 if(isinRect(gui_mouse_x(),gui_mouse_y(),x,y,x+15,y+13))
17397 {
17398 if(!over)
17399 {
17400 draw_question_button(dest, x, y, D_SELECTED);
17401 over=true;
17402 }
17403 }
17404 else
17405 {
17406 if(over)
17407 {
17408 draw_question_button(dest, x, y, 0);
17409 over=false;
17410 }
17411 }
17412 }
17413
17414 return over;
17415 }
17416
17417
17418 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
17419 {
17420 return D_O_K;
17421 }
17422
17423 int32_t d_maptile_proc(int32_t msg, DIALOG *d, int32_t)
17424 {
17425 switch(msg)
17426 {
17427 case MSG_CLICK:
17428 if(select_tile(d->d1,d->d2,1,d->fg,true, 0, true))
17429 return D_REDRAW;
17430
17431 case MSG_DRAW:
17432 {
17433 int32_t dw = d->w;
17434 int32_t dh = d->h;
17435
17436 if(d->dp2==(void*)1)
17437 {
17438 dw /= 2;
17439 dh /= 2;
17440 }
17441
17442 BITMAP *buf = create_bitmap_ex(8,dw,dh);
17443
17444 if(buf)
17445 {
17446 clear_bitmap(buf);
17447
17448 for(int32_t y=0; y<dh; y+=16)
17449 for(int32_t x=0; x<dw; x+=16)
17450 {
17451 if(d->d1)
17452 puttile16(buf,d->d1+(y>>4)*20+(x>>4),x,y,d->fg,0);
17453 }
17454
17455 if(d->dp2==(void*)1)
17456 stretch_blit(buf,screen,0,0,dw,dh,d->x-1,d->y-1,dw*2,dh*2);
17457 else
17458 blit(buf,screen,0,0,d->x,d->y,dw,dh);
17459
17460 destroy_bitmap(buf);
17461 }
17462 }
17463 }
17464
17465 return D_O_K;
17466 }
17467
17468 static int32_t last_combo=0;
17469 static int32_t last_cset=0;
17470
3/4
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98292 times.
✓ Branch 3 taken 12 times.
98304 static combo_alias temp_aliases[MAXCOMBOALIASES];
17471
17472 static char comboa_str_buf[32];
17473
17474 int32_t d_comboalist_proc(int32_t msg,DIALOG *d,int32_t c)
17475 {
17476 int32_t d1 = d->d1;
17477 int32_t ret = jwin_droplist_proc(msg,d,c);
17478 comboa_cnt = d->d1;
17479
17480 if(d1!=d->d1)
17481 {
17482 set_comboaradio(temp_aliases[comboa_cnt].layermask);
17483 return D_REDRAW;
17484 }
17485
17486 return ret;
17487 }
17488
17489 const char *comboalist(int32_t index, int32_t *list_size)
17490 {
17491 if(index>=0)
17492 {
17493 bound(index,0,MAXCOMBOALIASES-1);
17494 sprintf(comboa_str_buf,"%d",index);
17495 return comboa_str_buf;
17496 }
17497
17498 *list_size=MAXCOMBOALIASES;
17499 return NULL;
17500 }
17501
17502 extern int32_t scheme[jcMAX];
17503
17504 int32_t d_comboa_proc(int32_t msg,DIALOG *d,int32_t c)
17505 {
17506 //these are here to bypass compiler warnings about unused arguments
17507 c=c;
17508
17509 combo_alias *combo;
17510 combo = &temp_aliases[comboa_cnt];
17511 int32_t position;
17512 int32_t cur_layer, temp_layer;
17513 int32_t lay_count=0;
17514 int32_t size = 2;
17515
17516 int32_t cx1=(gui_mouse_x()-d->x-(120-(combo->width*8)));
17517 int32_t cy1=(gui_mouse_y()-d->y-(80-(combo->height*8)));
17518 int32_t cx=cx1/(16*size);
17519 int32_t cy=cy1/(16*size);
17520
17521 int32_t co,cs;
17522
17523
17524 switch(msg)
17525 {
17526 case MSG_CLICK:
17527 if((cx>combo->width)||(cx1<0))
17528 return D_O_K;
17529
17530 if((cy>combo->height)||(cy1<0))
17531 return D_O_K;
17532
17533 for(int32_t j=0; j<layer_cnt; j++)
17534 {
17535 if(combo->layermask&(1<<j))
17536 lay_count++;
17537 }
17538
17539 position=(lay_count)*(combo->width+1)*(combo->height+1);
17540 position+=(cy*(combo->width+1))+cx;
17541
17542 if(key[KEY_LSHIFT]||key[KEY_RSHIFT])
17543 {
17544 combo->combos[position] = 0;
17545 combo->csets[position] = 0;
17546
17547 while(gui_mouse_b())
17548 {
17549 /* do nothing */
17550 rest(1);
17551 }
17552
17553 return D_REDRAW;
17554 }
17555
17556 co=combo->combos[position];
17557 cs=combo->csets[position];
17558
17559 if((co==0)||(key[KEY_ZC_LCONTROL]))
17560 {
17561 co=last_combo;
17562 cs=last_cset;
17563 }
17564
17565 if((select_combo_2(co,cs)))
17566 {
17567 last_combo = co;
17568 last_cset = cs;
17569
17570 combo->combos[position]=co;
17571 combo->csets[position]=cs;
17572 }
17573
17574 return D_REDRAW;
17575 break;
17576
17577 case MSG_DRAW:
17578 BITMAP *buf = create_bitmap_ex(8,d->w,d->h);
17579
17580 if(buf)
17581 {
17582 clear_bitmap(buf);
17583
17584 for(int32_t z=0; z<=comboa_lmasktotal(combo->layermask); z++)
17585 {
17586 int32_t k=0;
17587 cur_layer=0;
17588 temp_layer=combo->layermask;
17589
17590 while((temp_layer!=0)&&(k<z))
17591 {
17592 if(temp_layer&1)
17593 {
17594 k++;
17595 }
17596
17597 cur_layer++;
17598 temp_layer = temp_layer>>1;
17599 }
17600
17601 for(int32_t y=0; (y<d->h)&&((y/16)<=combo->height); y+=16)
17602 {
17603 for(int32_t x=0; (x<d->w)&&((x/16)<=combo->width); x+=16)
17604 {
17605 int32_t cpos = (z*(combo->width+1)*(combo->height+1))+(((y/16)*(combo->width+1))+(x/16));
17606
17607 if(combo->combos[cpos])
17608 {
17609 if(!((d-1)->flags&D_SELECTED)||(cur_layer==layer_cnt))
17610 {
17611 if(z==0)
17612 {
17613 puttile16(buf,combobuf[combo->combos[cpos]].tile,x,y,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
17614 }
17615 else
17616 {
17617 overtile16(buf,combobuf[combo->combos[cpos]].tile,x,y,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
17618 }
17619 }
17620 }
17621 }
17622 }
17623 }
17624
17625 rectfill(screen, d->x-2,d->y-2,d->x+256+2,d->y+176+2,jwin_pal[jcBOX]);
17626 int32_t dx = 120-(combo->width*8)+d->x;
17627 int32_t dy = 80-(combo->height*8)+d->y;
17628 stretch_blit(buf,screen,0,0,(combo->width+1)*16,(combo->height+1)*16,dx,dy,(combo->width+1)*16*size,(combo->height+1)*16*size);
17629 //blit(buf,screen,0,0,120-(combo->width*8)+d->x,80-(combo->height*8)+d->y,(combo->width+1)*16,(combo->height+1)*16);
17630 (d-11)->w = (combo->width+1)*16*size+2;
17631 (d-11)->h = (combo->height+1)*16*size+2;
17632 (d-11)->x = 120-(combo->width*8)+4*size+2+(d-14)->x;
17633 (d-11)->y = 80-(combo->height*8)+25*size+2+(d-14)->y;
17634 object_message((d-11),MSG_DRAW,0);
17635
17636 destroy_bitmap(buf);
17637 }
17638
17639 break;
17640 }
17641
17642 return D_O_K;
17643 }
17644
17645 void draw_combo_alias_thumbnail(BITMAP *dest, combo_alias const* combo, int32_t x, int32_t y, int32_t size)
17646 {
17647 if(!combo->combo)
17648 {
17649 int32_t cur_layer, temp_layer;
17650
17651 int32_t cw=combo->width+1;
17652 int32_t ch=combo->height+1;
17653 int32_t dw=cw<<4;
17654 int32_t dh=ch<<4;
17655 int32_t sw=16, sh=16, sx=0, sy=0;
17656
17657 if(cw<ch)
17658 {
17659 sw=((cw<<4)/ch);
17660 sx=((16-sw)>>1);
17661 }
17662 else
17663 {
17664 sh=((ch<<4)/cw);
17665 sy=((16-sh)>>1);
17666 }
17667
17668 BITMAP *buf = create_bitmap_ex(8,dw,dh);
17669 BITMAP *buf2 = create_bitmap_ex(8, 16*size, 16*size);
17670 clear_bitmap(buf);
17671 clear_bitmap(buf2);
17672
17673 if(buf&&(combo->width>0||combo->height>0||combo->combos[0]>0))
17674 {
17675 clear_bitmap(buf);
17676
17677 for(int32_t z=0; z<=comboa_lmasktotal(combo->layermask); z++)
17678 {
17679 int32_t k=0;
17680 cur_layer=0;
17681 temp_layer=combo->layermask;
17682
17683 while((temp_layer!=0)&&(k<z))
17684 {
17685 if(temp_layer&1)
17686 {
17687 k++;
17688 }
17689
17690 cur_layer++;
17691 temp_layer = temp_layer>>1;
17692 }
17693
17694 for(int32_t y2=0; (y2<dh)&&((y2>>4)<=combo->height); y2+=16)
17695 {
17696 for(int32_t x2=0; (x2<dw)&&((x2>>4)<=combo->width); x2+=16)
17697 {
17698 int32_t cpos = (z*(combo->width+1)*(combo->height+1))+(((y2/16)*(combo->width+1))+(x2/16));
17699
17700 if(combo->combos[cpos])
17701 {
17702 if(z==0)
17703 {
17704 puttile16(buf,combobuf[combo->combos[cpos]].tile,x2,y2,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
17705 }
17706 else
17707 {
17708 overtile16(buf,combobuf[combo->combos[cpos]].tile,x2,y2,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
17709 }
17710 }
17711 }
17712 }
17713 }
17714
17715 stretch_blit(buf, buf2, 0, 0, (cw*16), (ch*16), sx*size, sy*size, sw*size, sh*size);
17716 blit(buf2, dest, 0, 0, x, y, 16*size, 16*size);
17717 }
17718 else
17719 {
17720 rectfill(dest,x,y,x+16*size-1,y+16*size-1,0);
17721 rectfill(dest,x+3*size,y+3*size,x+12*size,y+12*size,vc(4));
17722 }
17723
17724 if(buf)
17725 destroy_bitmap(buf);
17726
17727 if(buf2)
17728 destroy_bitmap(buf2);
17729 }
17730 else
17731 {
17732 if(combobuf[combo->combo].tile>0)
17733 {
17734 rectfill(dest,x,y,x+16*size-1,y+16*size-1,0);
17735 put_combo(dest, x, y, combo->combo, combo->cset, 0, 0, size);
17736 }
17737 else
17738 {
17739 rectfill(dest,x,y,x+16*size-1,y+16*size-1,0);
17740 rectfill(dest,x+3*size,y+3*size,x+12*size,y+12*size,vc(4));
17741 }
17742 }
17743 }
17744
17745 int32_t d_comboat_proc(int32_t msg,DIALOG *d,int32_t)
17746 {
17747 switch(msg)
17748 {
17749 case MSG_CLICK:
17750 {
17751 int32_t c2;
17752 int32_t cs;
17753 c2=temp_aliases[comboa_cnt].combo;
17754 cs=temp_aliases[comboa_cnt].cset;
17755
17756 if(gui_mouse_b()&2) //right mouse button
17757 {
17758 if(c2==0&&cs==0&&!(gui_mouse_b()&1))
17759 {
17760 return D_O_K;
17761 }
17762
17763 temp_aliases[comboa_cnt].combo=0;
17764 temp_aliases[comboa_cnt].cset=0;
17765 }
17766
17767 if(gui_mouse_b()&1) //left mouse button
17768 {
17769 if(select_combo_2(c2, cs))
17770 {
17771 temp_aliases[comboa_cnt].combo=c2;
17772 temp_aliases[comboa_cnt].cset=cs;
17773 }
17774
17775 return D_REDRAW;
17776 }
17777 else
17778 {
17779 return D_REDRAWME;
17780 }
17781 }
17782 break;
17783
17784 case MSG_DRAW:
17785 draw_combo_alias_thumbnail(screen, &temp_aliases[comboa_cnt], d->x-1, d->y-1,2);
17786 break;
17787
17788 default:
17789 break;
17790 }
17791
17792 return D_O_K;
17793 }
17794
17795 int32_t d_comboa_radio_proc(int32_t msg,DIALOG *d,int32_t c);
17796
17797 static DIALOG orgcomboa_dlg[] =
17798 {
17799 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
17800 { jwin_win_proc, 0, 0, 200, 161, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Organize Combo Aliases", NULL, NULL },
17801 { jwin_button_proc, 27, 130, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
17802 { jwin_button_proc, 112, 130, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
17803
17804 { jwin_radio_proc, 10, 40, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Copy", NULL, NULL },
17805 { jwin_text_proc, 10, 50, 33, 9, 0, 0, 0, 0, 0, 0, (void *) "", NULL, NULL },
17806 // { jwin_radio_proc, 10, 50, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Move", NULL, NULL },
17807 { jwin_radio_proc, 10, 60, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Swap", NULL, NULL },
17808 /* 6 */ { jwin_edit_proc, 110, 35, 32, 16, vc(12), vc(1), 0, 0, 4, 0, NULL, NULL, NULL },
17809 { jwin_edit_proc, 110, 55, 32, 16, vc(12), vc(1), 0, 0, 4, 0, NULL, NULL, NULL },
17810 { jwin_text_proc, 60, 40, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Source", NULL, NULL },
17811 { jwin_text_proc, 60, 60, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Dest", NULL, NULL},
17812 { jwin_radio_proc, 10, 80, 60, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Insert new (before source)", NULL, NULL },
17813 { jwin_radio_proc, 10, 100, 60, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Delete source", NULL, NULL },
17814 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17815 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17816 };
17817
17818 static DIALOG newcomboa_dlg[] =
17819 {
17820 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
17821 { jwin_win_proc, 0, 0, 200, 161, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combo Alias Properties", NULL, NULL },
17822 { jwin_button_proc, 27, 130, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
17823 { jwin_button_proc, 112, 130, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
17824 { jwin_text_proc, 24, 34, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Alias Width", NULL, NULL },
17825 { jwin_text_proc, 24, 52, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Alias Height", NULL, NULL },
17826 { jwin_text_proc, 24, 70, 100, 8, 0, 0, 0, 0, 0, 0, (void *) "Layers to Draw On:", NULL, NULL },
17827 { jwin_edit_proc, 104, 30, 28-6, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
17828 { jwin_edit_proc, 122, 48, 28-6, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
17829 { jwin_check_proc, 24, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "1", NULL, NULL },
17830 { jwin_check_proc, 50, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "2", NULL, NULL },
17831 { jwin_check_proc, 76, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "3", NULL, NULL },
17832 { jwin_check_proc, 102, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "4", NULL, NULL },
17833 { jwin_check_proc, 128, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "5", NULL, NULL },
17834 { jwin_check_proc, 154, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "6", NULL, NULL },
17835
17836
17837 // { jwin_text_proc, 24, 106, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Copy to :", NULL, NULL },
17838 //15
17839 // { jwin_edit_proc, 100, 100, 28-6, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
17840 // { jwin_check_proc, 84, 106, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "", NULL, NULL },
17841
17842 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17843 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17844 };
17845
17846 bool swapComboAlias(int32_t source, int32_t dest)
17847 {
17848 if(source==dest)
17849 return false;
17850 zc_swap(temp_aliases[source],temp_aliases[dest]);
17851 return true;
17852 }
17853
17854
17855 bool copyComboAlias(int32_t source, int32_t dest)
17856 {
17857 if(source == dest)
17858 return false;
17859 temp_aliases[dest] = temp_aliases[source];
17860 return true;
17861 }
17862
17863 int32_t getcurrentcomboalias();
17864
17865 int32_t onOrgComboAliases()
17866 {
17867 char cSrc[8];
17868 char cDest[8];
17869 sprintf(cSrc,"%d", getcurrentcomboalias());
17870 strcpy(cDest,cSrc);
17871 int32_t iSrc = 0;
17872 int32_t iDest = 0;
17873
17874 //sprintf(cSrc,"0");
17875 //sprintf(cDest,"0");
17876 orgcomboa_dlg[0].dp2=get_zc_font(font_lfont);
17877 orgcomboa_dlg[6].dp= cSrc;
17878 orgcomboa_dlg[7].dp= cDest;
17879 int32_t ret = 1;
17880 large_dialog(orgcomboa_dlg);
17881 do
17882 {
17883 iSrc = atoi((char*)orgcomboa_dlg[6].dp);
17884 iDest = atoi((char*)orgcomboa_dlg[7].dp);
17885 ret = do_zqdialog(orgcomboa_dlg,-1);
17886
17887 if(ret!=1) return ret;
17888
17889 if((atoi((char*) orgcomboa_dlg[6].dp))<0 || (atoi((char*) orgcomboa_dlg[6].dp)) > MAXCOMBOALIASES-1)
17890 {
17891 char buf[100];
17892 snprintf(buf, 100, "Invalid source (range 0-%d)", MAXCOMBOALIASES-1);
17893 buf[99]='\0';
17894 jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
17895 ret = 1;
17896 }
17897
17898 // 10,11=ins, del
17899 if(orgcomboa_dlg[10].flags & D_SELECTED) //insert
17900 {
17901 for(int32_t j=MAXCOMBOALIASES-1; j>(atoi((char*) orgcomboa_dlg[6].dp)); --j)
17902 copyComboAlias(j-1,j);
17903 ret = -1;
17904 }
17905
17906 if(orgcomboa_dlg[11].flags & D_SELECTED) //delete
17907 {
17908 for(int32_t j=(atoi((char*) orgcomboa_dlg[6].dp)); j<MAXCOMBOALIASES-1; ++j)
17909 copyComboAlias(j+1,j);
17910 ret = -1;
17911 }
17912
17913 if((atoi((char*) orgcomboa_dlg[6].dp)) == (atoi((char*) orgcomboa_dlg[7].dp)))
17914 {
17915 jwin_alert("Error","Source and dest can't be the same.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
17916 ret = 1;
17917 }
17918
17919 if((atoi((char*) orgcomboa_dlg[7].dp)) < 0 || (atoi((char*) orgcomboa_dlg[7].dp)) > MAXCOMBOALIASES-1)
17920 {
17921 char buf[100];
17922 snprintf(buf, 100, "Invalid dest (range 0-%d)", MAXCOMBOALIASES-1);
17923 buf[99]='\0';
17924
17925 jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
17926 ret = 1;
17927 }
17928
17929 if(orgcomboa_dlg[3].flags & D_SELECTED) //copy
17930 {
17931 copyComboAlias((atoi((char*) orgcomboa_dlg[6].dp)),(atoi((char*) orgcomboa_dlg[7].dp)));
17932 ret = -1;
17933 }
17934
17935 if(orgcomboa_dlg[5].flags & D_SELECTED) //swap
17936 {
17937 swapComboAlias((atoi((char*) orgcomboa_dlg[6].dp)),(atoi((char*) orgcomboa_dlg[7].dp)));
17938 ret = -1;
17939 }
17940 }
17941 while(ret==1);
17942 return ret;
17943 }
17944
17945 int32_t onNewComboAlias()
17946 {
17947 combo_alias *combo;
17948 combo = &temp_aliases[comboa_cnt];
17949
17950 char cwidth[5];
17951 char cheight[5];
17952 // char cp[3];
17953
17954 word temp_combos[16*11*7];
17955 byte temp_csets[16*11*7];
17956 sprintf(cwidth, "%d", combo->width+1);
17957 sprintf(cheight, "%d", combo->height+1);
17958 int32_t old_count = (comboa_lmasktotal(combo->layermask)+1)*(combo->width+1)*(combo->height+1);
17959 int32_t old_width=combo->width;
17960 int32_t old_height=combo->height;
17961 int32_t oldlayer=combo->layermask;
17962
17963 for(int32_t i=0; i<old_count; i++)
17964 {
17965 temp_csets[i] = combo->csets[i];
17966 temp_combos[i] = combo->combos[i];
17967 }
17968
17969 newcomboa_dlg[0].dp2 = get_zc_font(font_lfont);
17970 newcomboa_dlg[6].dp = cwidth;
17971 newcomboa_dlg[7].dp = cheight;
17972 newcomboa_dlg[8].flags = (combo->layermask&1)? D_SELECTED : 0;
17973 newcomboa_dlg[9].flags = (combo->layermask&2)? D_SELECTED : 0;
17974 newcomboa_dlg[10].flags = (combo->layermask&4)? D_SELECTED : 0;
17975 newcomboa_dlg[11].flags = (combo->layermask&8)? D_SELECTED : 0;
17976 newcomboa_dlg[12].flags = (combo->layermask&16)? D_SELECTED : 0;
17977 newcomboa_dlg[13].flags = (combo->layermask&32)? D_SELECTED : 0;
17978
17979 large_dialog(newcomboa_dlg);
17980
17981 int32_t ret = do_zqdialog(newcomboa_dlg,-1);
17982
17983 if(ret==1)
17984 {
17985 combo->width = ((atoi(cwidth)-1)<16)?zc_max(0,(atoi(cwidth)-1)):15;
17986 combo->height = ((atoi(cheight)-1)<11)?zc_max(0,(atoi(cheight)-1)):10;
17987 combo->layermask=0;
17988 combo->layermask |= (newcomboa_dlg[8].flags&D_SELECTED)?1:0;
17989 combo->layermask |= (newcomboa_dlg[9].flags&D_SELECTED)?2:0;
17990 combo->layermask |= (newcomboa_dlg[10].flags&D_SELECTED)?4:0;
17991 combo->layermask |= (newcomboa_dlg[11].flags&D_SELECTED)?8:0;
17992 combo->layermask |= (newcomboa_dlg[12].flags&D_SELECTED)?16:0;
17993 combo->layermask |= (newcomboa_dlg[13].flags&D_SELECTED)?32:0;
17994
17995 int32_t new_count = (comboa_lmasktotal(combo->layermask)+1)*(combo->width+1)*(combo->height+1);
17996
17997 combo->combos.clear();
17998 combo->csets.clear();
17999
18000 int32_t j=1;
18001 int32_t old_size=(old_width+1)*(old_height+1);
18002 int32_t new_start[7] =
18003 {
18004 0,
18005 ((combo->width+1)*(combo->height+1)*(1)),
18006 ((combo->width+1)*(combo->height+1)*(2)),
18007 ((combo->width+1)*(combo->height+1)*(3)),
18008 ((combo->width+1)*(combo->height+1)*(4)),
18009 ((combo->width+1)*(combo->height+1)*(5)),
18010 ((combo->width+1)*(combo->height+1)*(6))
18011 };
18012 int32_t new_layers[6] = {0,0,0,0,0,0};
18013 int32_t temp_layer = combo->layermask;
18014 int32_t temp_old = oldlayer;
18015 int32_t old_layers[6] = {0,0,0,0,0,0};
18016 int32_t k=1;
18017
18018 for(int32_t i=0; (i<6)&&(temp_layer!=0); j++,temp_layer>>=1,temp_old>>=1)
18019 {
18020 if(temp_layer&1)
18021 {
18022 new_layers[i] = j;
18023 //if(oldlayer&(1<<(j-1))) old_layers[i] = k++;
18024 i++;
18025 }
18026
18027 if(temp_old&1)
18028 {
18029 if(temp_layer&1)
18030 {
18031 old_layers[i-1] = k;
18032 }
18033
18034 k++;
18035 }
18036 }
18037
18038 for(int32_t i=0; i<new_count; i++)
18039 {
18040 if(i>=new_start[6])
18041 {
18042 //oldl=oldlayer>>(new_layers[5]-1);
18043 j=i-new_start[6];
18044
18045 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[5]-1))))
18046 {
18047 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[5])];
18048 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[5])];
18049 }
18050 else
18051 {
18052 combo->combos[i] = 0;
18053 combo->csets[i] = 0;
18054 }
18055 }
18056 else if(i>=new_start[5])
18057 {
18058 //oldl=oldlayer>>(new_layers[4]-1);
18059 j=i-new_start[5];
18060
18061 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[4]-1))))
18062 {
18063 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[4])];
18064 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[4])];
18065 }
18066 else
18067 {
18068 combo->combos[i] = 0;
18069 combo->csets[i] = 0;
18070 }
18071 }
18072 else if(i>=new_start[4])
18073 {
18074 //oldl=oldlayer>>(new_layers[3]-1);
18075 j=i-new_start[4];
18076
18077 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[3]-1))))
18078 {
18079 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[3])];
18080 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[3])];
18081 }
18082 else
18083 {
18084 combo->combos[i] = 0;
18085 combo->csets[i] = 0;
18086 }
18087 }
18088 else if(i>=new_start[3])
18089 {
18090 //oldl=oldlayer>>(new_layers[2]-1);
18091 j=i-new_start[3];
18092
18093 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[2]-1))))
18094 {
18095 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[2])];
18096 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[2])];
18097 }
18098 else
18099 {
18100 combo->combos[i] = 0;
18101 combo->csets[i] = 0;
18102 }
18103 }
18104 else if(i>=new_start[2])
18105 {
18106 //oldl=oldlayer>>(new_layers[1]-1);
18107 j=i-new_start[2];
18108
18109 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[1]-1))))
18110 {
18111 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[1])];
18112 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[1])];
18113 }
18114 else
18115 {
18116 combo->combos[i] = 0;
18117 combo->csets[i] = 0;
18118 }
18119 }
18120 else if(i>=new_start[1])
18121 {
18122 //oldl=oldlayer>>(new_layers[0]-1);
18123 j=i-new_start[1];
18124
18125 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[0]-1))))
18126 {
18127 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[0])];
18128 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[0])];
18129 }
18130 else
18131 {
18132 combo->combos[i] = 0;
18133 combo->csets[i] = 0;
18134 }
18135 }
18136 else if(i>=new_start[0])
18137 {
18138 if(((i/(combo->width+1))<=old_height)&&((i%(combo->width+1))<=old_width))
18139 {
18140 combo->combos[i] = temp_combos[(i%(combo->width+1))+((old_width+1)*(i/(combo->width+1)))];
18141 combo->csets[i] = temp_csets[(i%(combo->width+1))+((old_width+1)*(i/(combo->width+1)))];
18142 }
18143 else
18144 {
18145 combo->combos[i] = 0;
18146 combo->csets[i] = 0;
18147 }
18148 }
18149 }
18150
18151 set_comboaradio(combo->layermask);
18152 }
18153
18154 return ret;
18155 }
18156
18157 int32_t d_orgcomboa_proc(int32_t msg, DIALOG *d, int32_t c)
18158 {
18159 //these are here to bypass compiler warnings about unused arguments
18160 c=c;
18161
18162 int32_t down=0;
18163 int32_t selected=(d->flags&D_SELECTED)?1:0;
18164 int32_t last_draw;
18165
18166 switch(msg)
18167 {
18168
18169 case MSG_DRAW:
18170 {
18171 FONT *tfont=font;
18172 font=get_zc_font(font_lfont_l);
18173 jwin_draw_text_button(screen, d->x, d->y, d->w, d->h, (char*)d->dp, d->flags, true);
18174 font=tfont;
18175 }
18176 break;
18177
18178 case MSG_WANTFOCUS:
18179 return D_WANTFOCUS;
18180
18181 case MSG_KEY:
18182 /* close dialog? */
18183 onOrgComboAliases();
18184 return D_REDRAW;
18185
18186 /* or just toggle */
18187 /*d->flags ^= D_SELECTED;
18188 object_message(d, MSG_DRAW, 0);
18189 break;*/
18190
18191 case MSG_CLICK:
18192 last_draw = 0;
18193
18194 /* track the mouse until it is released */
18195 while(gui_mouse_b())
18196 {
18197 down = mouse_in_rect(d->x, d->y, d->w, d->h);
18198
18199 /* redraw? */
18200 if(last_draw != down)
18201 {
18202 if(down != selected)
18203 d->flags |= D_SELECTED;
18204 else
18205 d->flags &= ~D_SELECTED;
18206
18207 object_message(d, MSG_DRAW, 0);
18208 last_draw = down;
18209 }
18210
18211 /* let other objects continue to animate */
18212 broadcast_dialog_message(MSG_IDLE, 0);
18213 }
18214
18215 /* redraw in normal state */
18216 if(down)
18217 {
18218 if(d->flags&D_EXIT)
18219 {
18220 d->flags &= ~D_SELECTED;
18221 object_message(d, MSG_DRAW, 0);
18222 }
18223 }
18224
18225 /* should we close the dialog? */
18226 if(down)
18227 {
18228 onOrgComboAliases();
18229 return D_REDRAW;
18230 }
18231
18232 break;
18233 }
18234
18235 return D_O_K;
18236 }
18237
18238 int32_t d_comboabutton_proc(int32_t msg, DIALOG *d, int32_t c)
18239 {
18240 //these are here to bypass compiler warnings about unused arguments
18241 c=c;
18242
18243 int32_t down=0;
18244 int32_t selected=(d->flags&D_SELECTED)?1:0;
18245 int32_t last_draw;
18246
18247 switch(msg)
18248 {
18249
18250 case MSG_DRAW:
18251 {
18252 FONT *tfont=font;
18253 font=get_zc_font(font_lfont_l);
18254 jwin_draw_text_button(screen, d->x, d->y, d->w, d->h, (char*)d->dp, d->flags, true);
18255 font=tfont;
18256 }
18257 break;
18258
18259 case MSG_WANTFOCUS:
18260 return D_WANTFOCUS;
18261
18262 case MSG_KEY:
18263 /* close dialog? */
18264 onNewComboAlias();
18265 return D_REDRAW;
18266
18267 /* or just toggle */
18268 /*d->flags ^= D_SELECTED;
18269 object_message(d, MSG_DRAW, 0);
18270 break;*/
18271
18272 case MSG_CLICK:
18273 last_draw = 0;
18274
18275 /* track the mouse until it is released */
18276 while(gui_mouse_b())
18277 {
18278 down = mouse_in_rect(d->x, d->y, d->w, d->h);
18279
18280 /* redraw? */
18281 if(last_draw != down)
18282 {
18283 if(down != selected)
18284 d->flags |= D_SELECTED;
18285 else
18286 d->flags &= ~D_SELECTED;
18287
18288 object_message(d, MSG_DRAW, 0);
18289 last_draw = down;
18290 }
18291
18292 /* let other objects continue to animate */
18293 broadcast_dialog_message(MSG_IDLE, 0);
18294 }
18295
18296 /* redraw in normal state */
18297 if(down)
18298 {
18299 if(d->flags&D_EXIT)
18300 {
18301 d->flags &= ~D_SELECTED;
18302 object_message(d, MSG_DRAW, 0);
18303 }
18304 }
18305
18306 /* should we close the dialog? */
18307 if(down)
18308 {
18309 onNewComboAlias();
18310 return D_REDRAW;
18311 }
18312
18313 break;
18314 }
18315
18316 return D_O_K;
18317 }
18318
18319 int32_t d_comboacheck_proc(int32_t msg, DIALOG *d, int32_t c)
18320 {
18321 int32_t temp = d->flags&D_SELECTED;
18322 int32_t ret=jwin_checkfont_proc(msg,d,c);
18323
18324 if(temp != (d->flags&D_SELECTED))
18325 {
18326 return D_REDRAW;
18327 }
18328
18329 return ret;
18330 }
18331
18332 12 static ListData comboa_list(comboalist, &font);
18333
18334 static DIALOG editcomboa_dlg[] =
18335 {
18336 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
18337 { jwin_win_proc, 0, 0, 320, 240, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combo Alias Edit", NULL, NULL },
18338 { jwin_button_proc, 148, 212, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
18339 { jwin_button_proc, 232, 212, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
18340 { jwin_frame_proc, 4+121, 28+81, 1, 1, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
18341 { d_comboabutton_proc, 25, 212, 81, 21, vc(14), vc(1), 'p', D_EXIT, 0, 0, (void *) "&Properties", NULL, NULL },
18342 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18343 { d_comboa_radio_proc, 285, 44, 30, 8+1, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "0", NULL, NULL },
18344 { d_comboa_radio_proc, 285, 54, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "1", NULL, NULL },
18345 { d_comboa_radio_proc, 285, 64, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "2", NULL, NULL },
18346 { d_comboa_radio_proc, 285, 74, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "3", NULL, NULL },
18347 { d_comboa_radio_proc, 285, 84, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "4", NULL, NULL },
18348
18349 { d_comboa_radio_proc, 285, 94, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "5", NULL, NULL },
18350 { d_comboa_radio_proc, 285, 104, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "6", NULL, NULL },
18351 { d_comboacheck_proc, 285, 164, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
18352 { d_comboa_proc, 6, 27, 256, 176, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18353 { jwin_ctext_proc, 290, 176, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Only Show", NULL, NULL },
18354 { jwin_ctext_proc, 290, 186, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Current", NULL, NULL },
18355 { jwin_ctext_proc, 290, 196, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Layer", NULL, NULL },
18356 { jwin_ctext_proc, 290, 122, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Thumbnail", NULL, NULL },
18357 { jwin_frame_proc, 280, 132, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
18358 { d_comboat_proc, 282, 134, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18359
18360 //21
18361 { d_orgcomboa_proc, 106, 212, 21, 21, vc(14), vc(1), 'p', D_EXIT, 0, 0, (void *) "&Org", NULL, NULL },
18362 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18363 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
18364 };
18365
18366 int32_t getcurrentcomboalias()
18367 {
18368 return editcomboa_dlg[5].d1;
18369 }
18370
18371 int32_t d_comboa_radio_proc(int32_t msg,DIALOG *d,int32_t c)
18372 {
18373 int32_t temp = layer_cnt;
18374 int32_t ret = jwin_radiofont_proc(msg,d,c);
18375
18376 if(editcomboa_dlg[6].flags&D_SELECTED) layer_cnt=0;
18377 else if(editcomboa_dlg[7].flags&D_SELECTED) layer_cnt=1;
18378 else if(editcomboa_dlg[8].flags&D_SELECTED) layer_cnt=2;
18379 else if(editcomboa_dlg[9].flags&D_SELECTED) layer_cnt=3;
18380 else if(editcomboa_dlg[10].flags&D_SELECTED) layer_cnt=4;
18381 else if(editcomboa_dlg[11].flags&D_SELECTED) layer_cnt=5;
18382 else if(editcomboa_dlg[12].flags&D_SELECTED) layer_cnt=6;
18383
18384 if(temp != layer_cnt)
18385 {
18386 return D_REDRAW;
18387 }
18388
18389 return ret;
18390 }
18391
18392 int32_t set_comboaradio(byte layermask)
18393 {
18394 if(editcomboa_dlg[7].flags&D_SELECTED) editcomboa_dlg[7].flags &= ~D_SELECTED;
18395
18396 if(editcomboa_dlg[8].flags&D_SELECTED) editcomboa_dlg[8].flags &= ~D_SELECTED;
18397
18398 if(editcomboa_dlg[9].flags&D_SELECTED) editcomboa_dlg[9].flags &= ~D_SELECTED;
18399
18400 if(editcomboa_dlg[10].flags&D_SELECTED) editcomboa_dlg[10].flags &= ~D_SELECTED;
18401
18402 if(editcomboa_dlg[11].flags&D_SELECTED) editcomboa_dlg[11].flags &= ~D_SELECTED;
18403
18404 if(editcomboa_dlg[12].flags&D_SELECTED) editcomboa_dlg[12].flags &= ~D_SELECTED;
18405
18406 if(!(layermask&1)) editcomboa_dlg[7].flags |= D_DISABLED;
18407 else editcomboa_dlg[7].flags &= ~D_DISABLED;
18408
18409 if(!(layermask&2)) editcomboa_dlg[8].flags |= D_DISABLED;
18410 else editcomboa_dlg[8].flags &= ~D_DISABLED;
18411
18412 if(!(layermask&4)) editcomboa_dlg[9].flags |= D_DISABLED;
18413 else editcomboa_dlg[9].flags &= ~D_DISABLED;
18414
18415 if(!(layermask&8)) editcomboa_dlg[10].flags |= D_DISABLED;
18416 else editcomboa_dlg[10].flags &= ~D_DISABLED;
18417
18418 if(!(layermask&16)) editcomboa_dlg[11].flags |= D_DISABLED;
18419 else editcomboa_dlg[11].flags &= ~D_DISABLED;
18420
18421 if(!(layermask&32)) editcomboa_dlg[12].flags |= D_DISABLED;
18422 else editcomboa_dlg[12].flags &= ~D_DISABLED;
18423
18424 editcomboa_dlg[6].flags |= D_SELECTED;
18425 layer_cnt=0;
18426 return 1;
18427 }
18428
18429 int32_t onEditComboPool()
18430 {
18431 call_cpool_dlg(combo_pool_pos);
18432 return D_O_K;
18433 }
18434 int32_t onEditAutoCombo()
18435 {
18436 call_autocombo_dlg(combo_auto_pos);
18437 return D_O_K;
18438 }
18439 int32_t onEditComboAlias()
18440 {
18441 comboa_cnt = combo_apos;
18442 reset_combo_animations();
18443 reset_combo_animations2();
18444
18445 for(int32_t i=0; i<MAXCOMBOALIASES; i++)
18446 temp_aliases[i] = combo_aliases[i];
18447
18448 editcomboa_dlg[0].dp2 = get_zc_font(font_lfont);
18449 set_comboaradio(temp_aliases[comboa_cnt].layermask);
18450 editcomboa_dlg[5].d1 = comboa_cnt;
18451
18452 bool small_d1 = editcomboa_dlg[0].d1==0;
18453 large_dialog(editcomboa_dlg,2);
18454
18455 if(small_d1)
18456 {
18457 for(int32_t i=6; i<=12; i++)
18458 {
18459 editcomboa_dlg[i].w=30*1.5;
18460 editcomboa_dlg[i].h=9*1.5;
18461 }
18462
18463 editcomboa_dlg[13].w=17*1.5;
18464 editcomboa_dlg[13].h=9*1.5;
18465 editcomboa_dlg[4].w=81*1.5;
18466 editcomboa_dlg[4].h=21*1.5;
18467 editcomboa_dlg[4].dp2=get_zc_font(font_lfont_l);
18468 editcomboa_dlg[21].w=21*1.5;
18469 editcomboa_dlg[21].h=21*1.5;
18470 editcomboa_dlg[21].dp2=get_zc_font(font_lfont_l);
18471 }
18472
18473 int32_t ret=do_zqdialog(editcomboa_dlg,-1);
18474
18475 if(ret==1)
18476 {
18477 saved=false;
18478
18479 for(int32_t i=0; i<MAXCOMBOALIASES; i++)
18480 combo_aliases[i] = temp_aliases[i];
18481 }
18482
18483 setup_combo_animations();
18484 setup_combo_animations2();
18485 return D_O_K;
18486 }
18487 void call_calias_dlg(int index)
18488 {
18489 combo_apos = comboa_cnt = index;
18490 onEditComboAlias();
18491 }
18492
18493 static char ffcombo_str_buf[MAXFFCS];
18494 static char fflink_str_buf[MAXFFCS];
18495
18496 BITMAP* ffcur;
18497
18498 const char *ffcombolist(int32_t index, int32_t *list_size)
18499 {
18500 if(index>=0)
18501 {
18502 bound(index,0,MAXFFCS-1);
18503 sprintf(ffcombo_str_buf,"%d",index+1);
18504 return ffcombo_str_buf;
18505 }
18506
18507 *list_size=MAXFFCS;
18508 return NULL;
18509 }
18510
18511 12 static ListData ffcombo_list(ffcombolist, &font);
18512
18513 static DIALOG ffcombo_sel_dlg[] =
18514 {
18515 12 { jwin_win_proc, 0, 0, 200, 179, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Choose Freeform Combo", NULL, NULL },
18516 12 { jwin_button_proc, 35, 152, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
18517 12 { jwin_button_proc, 104, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
18518 12 { d_ffcombolist_proc, 11, 24, 49, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 1, 0, (void *) &ffcombo_list, NULL, NULL },
18519 12 { d_comboframe_proc, 68, 23, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
18520 12 { d_bitmap_proc, 70, 25, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18521 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18522 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
18523 };
18524
18525 int32_t d_ffcombolist_proc(int32_t msg,DIALOG *d,int32_t c)
18526 {
18527 int32_t ret = jwin_droplist_proc(msg,d,c);
18528 int32_t d1 = d->d1;
18529 int32_t x=ffcombo_sel_dlg[0].x;
18530 int32_t y=ffcombo_sel_dlg[0].y;
18531 FONT *tempfont=(font);
18532 int32_t x2=text_length(tempfont, "Move Delay:")+4;
18533
18534 switch(msg)
18535 {
18536 case MSG_DRAW:
18537 if(!ffcur) return D_O_K;
18538
18539 BITMAP *buf = create_bitmap_ex(8,16,16);
18540
18541 if(buf)
18542 {
18543 clear_bitmap(buf);
18544 putcombo(buf,0,0,Map.CurrScr()->ffcs[d1].data,Map.CurrScr()->ffcs[d1].cset);
18545 stretch_blit(buf, ffcur, 0,0, 16, 16, 0, 0, ffcur->w, ffcur->h);
18546 destroy_bitmap(buf);
18547 }
18548
18549 object_message(&ffcombo_sel_dlg[5],MSG_DRAW,0);
18550
18551 int32_t xd = x+int32_t(68*1.5);
18552 int32_t y2 = y+int32_t(55*1.5);
18553 int32_t yd = 9;
18554
18555 rectfill(screen,xd,y2,xd+x2+100,y2+yd*14,jwin_pal[jcBOX]);
18556
18557 textprintf_ex(screen,tempfont,xd,y2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Combo #:");
18558 textprintf_ex(screen,tempfont,xd+x2,y2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].data);
18559
18560 textprintf_ex(screen,tempfont,xd,y2+yd,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"CSet #:");
18561 textprintf_ex(screen,tempfont,xd+x2,y2+yd,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].cset);
18562
18563 textprintf_ex(screen,tempfont,xd,y2+yd*2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"X Pos:");
18564 textprintf_ex(screen,tempfont,xd+x2,y2+yd*2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].x.getFloat());
18565
18566 textprintf_ex(screen,tempfont,xd,y2+yd*3,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Y Pos:");
18567 textprintf_ex(screen,tempfont,xd+x2,y2+yd*3,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].y.getFloat());
18568
18569 textprintf_ex(screen,tempfont,xd,y2+yd*4,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"X Speed:");
18570 textprintf_ex(screen,tempfont,xd+x2,y2+yd*4,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].vx.getFloat());
18571
18572 textprintf_ex(screen,tempfont,xd,y2+yd*5,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Y Speed:");
18573 textprintf_ex(screen,tempfont,xd+x2,y2+yd*5,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].vy.getFloat());
18574
18575 textprintf_ex(screen,tempfont,xd,y2+yd*6,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"X Accel:");
18576 textprintf_ex(screen,tempfont,xd+x2,y2+yd*6,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].ax.getFloat());
18577
18578 textprintf_ex(screen,tempfont,xd,y2+yd*7,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Y Accel:");
18579 textprintf_ex(screen,tempfont,xd+x2,y2+yd*7,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].ay.getFloat());
18580
18581 textprintf_ex(screen,tempfont,xd,y2+yd*8,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Linked To:");
18582 textprintf_ex(screen,tempfont,xd+x2,y2+yd*8,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].link);
18583
18584 textprintf_ex(screen,tempfont,xd,y2+yd*9,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Move Delay:");
18585 textprintf_ex(screen,tempfont,xd+x2,y2+yd*9,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].delay);
18586
18587 textprintf_ex(screen,tempfont,xd,y2+yd*10,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Combo W:");
18588 textprintf_ex(screen,tempfont,xd+x2,y2+yd*10,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffEffectWidth(d1)));
18589
18590 textprintf_ex(screen,tempfont,xd,y2+yd*11,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Combo H:");
18591 textprintf_ex(screen,tempfont,xd+x2,y2+yd*11,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffEffectHeight(d1)));
18592
18593 textprintf_ex(screen,tempfont,xd,y2+yd*12,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Tile W:");
18594 textprintf_ex(screen,tempfont,xd+x2,y2+yd*12,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffTileWidth(d1)));
18595
18596 textprintf_ex(screen,tempfont,xd,y2+yd*13,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Tile H:");
18597 textprintf_ex(screen,tempfont,xd+x2,y2+yd*13,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffTileHeight(d1)));
18598
18599 break;
18600 }
18601
18602 return ret;
18603 }
18604 int32_t onSelectFFCombo()
18605 {
18606 ffcombo_sel_dlg[0].dp2 = get_zc_font(font_lfont);
18607 ffcombo_sel_dlg[3].d1 = ff_combo;
18608 ffcur = create_bitmap_ex(8,32,32);
18609
18610 if(!ffcur) return D_O_K;
18611
18612 Map.CurrScr()->ensureFFC(MAXFFCS - 1);
18613 putcombo(ffcur,0,0,Map.CurrScr()->ffcs[ff_combo].data,Map.CurrScr()->ffcs[ff_combo].cset);
18614 ffcombo_sel_dlg[5].dp = ffcur;
18615
18616 bool resize = !(ffcombo_sel_dlg[0].d1);
18617 large_dialog(ffcombo_sel_dlg);
18618
18619 if(resize)
18620 {
18621 ffcombo_sel_dlg[5].x--;
18622 ffcombo_sel_dlg[5].y--;
18623 }
18624
18625 int32_t ret=do_zqdialog(ffcombo_sel_dlg,0);
18626
18627 while(ret==1)
18628 {
18629 ff_combo = ffcombo_sel_dlg[3].d1;
18630 mapscr* scr = active_visible_screen ? active_visible_screen->scr : Map.CurrScr();
18631 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
18632 call_ffc_dialog(ff_combo, scr, screen);
18633 ret=do_zqdialog(ffcombo_sel_dlg,0);
18634 }
18635
18636 destroy_bitmap(ffcur);
18637 return D_O_K;
18638 }
18639
18640 const char *globalscriptlist(int32_t index, int32_t *list_size);
18641 12 static ListData globalscript_list(globalscriptlist, &font);
18642 const char *playerscriptlist(int32_t index, int32_t *list_size);
18643 12 static ListData playerscript_list(playerscriptlist, &font);
18644
18645 const char *ffscriptlist(int32_t index, int32_t *list_size);
18646
18647 12 static ListData ffscript_list(ffscriptlist, &font);
18648
18649 char *strip_decimals(char *string)
18650 {
18651 int32_t len=(int32_t)strlen(string);
18652 char *src=(char *)malloc(len+1);
18653 char *tmpsrc=src;
18654 memcpy(src,string,len+1);
18655 memset(src,0,len+1);
18656
18657 for(size_t i=0; string[i]&&i<=strlen(string); i++)
18658 {
18659 *tmpsrc=string[i];
18660
18661 if(*tmpsrc=='.')
18662 {
18663 while(string[i+1]=='.'&&i<=strlen(string))
18664 {
18665 i++;
18666 }
18667 }
18668
18669 tmpsrc++;
18670 }
18671
18672 memcpy(string,src,len);
18673 free(src);
18674 return string;
18675 }
18676
18677 // Unused??? -L 6/6/11
18678 char *clean_numeric_string(char *string)
18679 {
18680 bool found_sign=false;
18681 bool found_decimal=false;
18682 int32_t len=(int32_t)strlen(string);
18683 char *src=(char *)malloc(len+1);
18684 char *tmpsrc=src;
18685 memcpy(src,string,len+1);
18686 memset(src,0,len+1);
18687
18688 // strip out non-numerical characters
18689 for(size_t i=0; string[i]&&i<=strlen(string); i++)
18690 {
18691 *tmpsrc=string[i];
18692
18693 if(*tmpsrc!='.'&&*tmpsrc!='-'&&*tmpsrc!='+'&&!isdigit(*tmpsrc))
18694 {
18695 while(*tmpsrc!='.'&&*tmpsrc!='-'&&*tmpsrc!='+'&&!isdigit(*tmpsrc))
18696 {
18697 i++;
18698 }
18699 }
18700
18701 tmpsrc++;
18702 }
18703
18704 len=(int32_t)strlen(src);
18705 char *src2=(char *)malloc(len+1);
18706 tmpsrc=src2;
18707 memcpy(src,src2,len+1);
18708 memset(src2,0,len+1);
18709
18710 // second purge
18711 for(size_t i=0; src[i]&&i<=strlen(src); i++)
18712 {
18713 *tmpsrc=src[i];
18714
18715 if(*tmpsrc=='-'||*tmpsrc=='+')
18716 {
18717 if(found_sign||found_decimal)
18718 {
18719 while(*tmpsrc=='-'||*tmpsrc=='+')
18720 {
18721 i++;
18722 }
18723 }
18724
18725 found_sign=true;
18726 }
18727
18728 if(*tmpsrc=='.')
18729 {
18730 if(found_decimal)
18731 {
18732 while(*tmpsrc=='.')
18733 {
18734 i++;
18735 }
18736 }
18737
18738 found_decimal=true;
18739 }
18740
18741 tmpsrc++;
18742 }
18743
18744 sprintf(string, "%s", src2);
18745 free(src);
18746 free(src2);
18747 return string;
18748 }
18749
18750 script_struct biglobal[NUMSCRIPTGLOBAL+1]; //global script
18751 int32_t biglobal_cnt = -1;
18752 script_struct biffs[NUMSCRIPTFFC]; //ff script
18753 int32_t biffs_cnt = -1;
18754 script_struct biitems[NUMSCRIPTITEM]; //item script
18755 int32_t biitems_cnt = -1;
18756 script_struct binpcs[NUMSCRIPTGUYS]; //npc script
18757 int32_t binpcs_cnt = -1;
18758
18759 script_struct bilweapons[NUMSCRIPTWEAPONS]; //lweapon script
18760 int32_t bilweapons_cnt = -1;
18761
18762 script_struct bieweapons[NUMSCRIPTWEAPONS]; //eweapon script
18763 int32_t bieweapons_cnt = -1;
18764
18765 script_struct bihero[NUMSCRIPTHERO]; //link script
18766 int32_t bihero_cnt = -1;
18767
18768 script_struct biscreens[NUMSCRIPTSCREEN]; //screen (screendata) script
18769 int32_t biscreens_cnt = -1;
18770
18771 script_struct bidmaps[NUMSCRIPTSDMAP]; //dmap (dmapdata) script
18772 int32_t bidmaps_cnt = -1;
18773
18774 script_struct biditemsprites[NUMSCRIPTSITEMSPRITE]; //dmap (dmapdata) script
18775 int32_t biitemsprites_cnt = -1;
18776
18777 script_struct bidcomboscripts[NUMSCRIPTSCOMBODATA]; //dmap (dmapdata) script
18778 int32_t bidcomboscripts_cnt = -1;
18779 //static char ffscript_str_buf[32];
18780
18781 void build_biglobal_list()
18782 {
18783 biglobal[0].first = "(None)";
18784 biglobal[0].second = -1;
18785 biglobal_cnt = 1;
18786
18787 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
18788 {
18789 if(globalmap[i].scriptname.length()==0)
18790 continue;
18791
18792 stringstream ss;
18793 ss << globalmap[i].scriptname << " (" << i << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
18794 biglobal[biglobal_cnt].first = ss.str();
18795 biglobal[biglobal_cnt].second = i;
18796 ++biglobal_cnt;
18797 }
18798
18799 // Blank out the rest of the list
18800 for(int32_t i=biglobal_cnt; i<NUMSCRIPTGLOBAL; ++i)
18801 {
18802 biglobal[i].first="";
18803 biglobal[i].second=-1;
18804 }
18805
18806 //Bubble sort! (doesn't account for gaps between scripts)
18807 for(int32_t i = 0; i < biglobal_cnt - 1; i++)
18808 {
18809 for(int32_t j = i + 1; j < biglobal_cnt; j++)
18810 {
18811 if(stricmp(biglobal[i].first.c_str(),biglobal[j].first.c_str()) > 0 && strcmp(biglobal[j].first.c_str(),""))
18812 zc_swap(biglobal[i],biglobal[j]);
18813 }
18814 }
18815
18816 biglobal_cnt = 0;
18817
18818 for(int32_t i = 0; i < NUMSCRIPTGLOBAL+1; ++i)
18819 if(biglobal[i].first.length() > 0)
18820 biglobal_cnt = i+1;
18821 }
18822
18823 6 void build_biffs_list()
18824 {
18825 6 biffs[0].first = "(None)";
18826 6 biffs[0].second = -1;
18827 6 biffs_cnt = 1;
18828
18829
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(int32_t i = 0; i < NUMSCRIPTFFC - 1; i++)
18830 {
18831
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 2992 times.
3066 if(ffcmap[i].scriptname.length()==0)
18832 2992 continue;
18833
18834 74 stringstream ss;
18835
5/10
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 74 times.
✗ Branch 9 not taken.
74 ss << ffcmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
18836
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 biffs[biffs_cnt].first = ss.str();
18837 74 biffs[biffs_cnt].second = i;
18838 74 biffs_cnt++;
18839 74 }
18840
18841 // Blank out the rest of the list
18842
2/2
✓ Branch 0 taken 2992 times.
✓ Branch 1 taken 6 times.
2998 for(int32_t i=biffs_cnt; i<NUMSCRIPTFFC; i++)
18843 {
18844 2992 biffs[i].first="";
18845 2992 biffs[i].second=-1;
18846 2992 }
18847
18848 //Bubble sort! (doesn't account for gaps between scripts)
18849
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 6 times.
80 for(int32_t i = 0; i < biffs_cnt - 1; i++)
18850 {
18851
2/2
✓ Branch 0 taken 1308 times.
✓ Branch 1 taken 74 times.
1382 for(int32_t j = i + 1; j < biffs_cnt; j++)
18852 {
18853
3/4
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 781 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 527 times.
1308 if(stricmp(biffs[i].first.c_str(),biffs[j].first.c_str()) > 0 && strcmp(biffs[j].first.c_str(),""))
18854 527 zc_swap(biffs[i],biffs[j]);
18855 1308 }
18856 74 }
18857
18858 6 biffs_cnt = 0;
18859
18860
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 6 times.
3078 for(int32_t i = 0; i < NUMSCRIPTFFC; i++)
18861
2/2
✓ Branch 0 taken 2992 times.
✓ Branch 1 taken 80 times.
3152 if(biffs[i].first.length() > 0)
18862 80 biffs_cnt = i+1;
18863 6 }
18864
18865 //npc scripts
18866 void build_binpcs_list()
18867 {
18868 binpcs[0].first = "(None)";
18869 binpcs[0].second = -1;
18870 binpcs_cnt = 1;
18871
18872 for(int32_t i = 0; i < NUMSCRIPTGUYS - 1; i++)
18873 {
18874 if(npcmap[i].scriptname.length()==0)
18875 continue;
18876
18877 stringstream ss;
18878 ss << npcmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
18879 binpcs[binpcs_cnt].first = ss.str();
18880 binpcs[binpcs_cnt].second = i;
18881 binpcs_cnt++;
18882 }
18883
18884 // Blank out the rest of the list
18885 for(int32_t i=binpcs_cnt; i<NUMSCRIPTGUYS; i++)
18886 {
18887 binpcs[i].first="";
18888 binpcs[i].second=-1;
18889 }
18890
18891 //Bubble sort! (doesn't account for gaps between scripts)
18892 for(int32_t i = 0; i < binpcs_cnt - 1; i++)
18893 {
18894 for(int32_t j = i + 1; j < binpcs_cnt; j++)
18895 {
18896 if(stricmp(binpcs[i].first.c_str(),binpcs[j].first.c_str()) > 0 && strcmp(binpcs[j].first.c_str(),""))
18897 zc_swap(binpcs[i],binpcs[j]);
18898 }
18899 }
18900
18901 binpcs_cnt = 0;
18902
18903 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
18904 if(binpcs[i].first.length() > 0)
18905 binpcs_cnt = i+1;
18906 }
18907
18908
18909 //lweapon scripts
18910 void build_bilweapons_list()
18911 {
18912 bilweapons[0].first = "(None)";
18913 bilweapons[0].second = -1;
18914 bilweapons_cnt = 1;
18915
18916 for(int32_t i = 0; i < NUMSCRIPTWEAPONS - 1; i++)
18917 {
18918 if(lwpnmap[i].scriptname.length()==0)
18919 continue;
18920
18921 stringstream ss;
18922 ss << lwpnmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
18923 bilweapons[bilweapons_cnt].first = ss.str();
18924 bilweapons[bilweapons_cnt].second = i;
18925 bilweapons_cnt++;
18926 }
18927
18928 // Blank out the rest of the list
18929 for(int32_t i=bilweapons_cnt; i<NUMSCRIPTWEAPONS; i++)
18930 {
18931 bilweapons[i].first="";
18932 bilweapons[i].second=-1;
18933 }
18934
18935 //Bubble sort! (doesn't account for gaps between scripts)
18936 for(int32_t i = 0; i < bilweapons_cnt - 1; i++)
18937 {
18938 for(int32_t j = i + 1; j < bilweapons_cnt; j++)
18939 {
18940 if(stricmp(bilweapons[i].first.c_str(),bilweapons[j].first.c_str()) > 0 && strcmp(bilweapons[j].first.c_str(),""))
18941 zc_swap(bilweapons[i],bilweapons[j]);
18942 }
18943 }
18944
18945 bilweapons_cnt = 0;
18946
18947 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
18948 if(bilweapons[i].first.length() > 0)
18949 bilweapons_cnt = i+1;
18950 }
18951
18952 //eweapon scripts
18953 void build_bieweapons_list()
18954 {
18955 bieweapons[0].first = "(None)";
18956 bieweapons[0].second = -1;
18957 bieweapons_cnt = 1;
18958
18959 for(int32_t i = 0; i < NUMSCRIPTWEAPONS - 1; i++)
18960 {
18961 if(ewpnmap[i].scriptname.length()==0)
18962 continue;
18963
18964 stringstream ss;
18965 ss << ewpnmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
18966 bieweapons[bieweapons_cnt].first = ss.str();
18967 bieweapons[bieweapons_cnt].second = i;
18968 bieweapons_cnt++;
18969 }
18970
18971 // Blank out the rest of the list
18972 for(int32_t i=bieweapons_cnt; i<NUMSCRIPTWEAPONS; i++)
18973 {
18974 bieweapons[i].first="";
18975 bieweapons[i].second=-1;
18976 }
18977
18978 //Bubble sort! (doesn't account for gaps between scripts)
18979 for(int32_t i = 0; i < bieweapons_cnt - 1; i++)
18980 {
18981 for(int32_t j = i + 1; j < bieweapons_cnt; j++)
18982 {
18983 if(stricmp(bieweapons[i].first.c_str(),bieweapons[j].first.c_str()) > 0 && strcmp(bieweapons[j].first.c_str(),""))
18984 zc_swap(bieweapons[i],bieweapons[j]);
18985 }
18986 }
18987
18988 bieweapons_cnt = 0;
18989
18990 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
18991 if(bieweapons[i].first.length() > 0)
18992 bieweapons_cnt = i+1;
18993 }
18994
18995 //player scripts
18996 void build_bihero_list()
18997 {
18998 bihero[0].first = "(None)";
18999 bihero[0].second = -1;
19000 bihero_cnt = 1;
19001
19002 for(int32_t i = 0; i < NUMSCRIPTHERO - 1; i++)
19003 {
19004 if(playermap[i].scriptname.length()==0)
19005 continue;
19006
19007 stringstream ss;
19008 ss << playermap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
19009 bihero[bihero_cnt].first = ss.str();
19010 bihero[bihero_cnt].second = i;
19011 bihero_cnt++;
19012 }
19013
19014 // Blank out the rest of the list
19015 for(int32_t i=bihero_cnt; i<NUMSCRIPTHERO; i++)
19016 {
19017 bihero[i].first="";
19018 bihero[i].second=-1;
19019 }
19020
19021 //Bubble sort! (doesn't account for gaps between scripts)
19022 for(int32_t i = 0; i < bihero_cnt - 1; i++)
19023 {
19024 for(int32_t j = i + 1; j < bihero_cnt; j++)
19025 {
19026 if(stricmp(bihero[i].first.c_str(),bihero[j].first.c_str()) > 0 && strcmp(bihero[j].first.c_str(),""))
19027 zc_swap(bihero[i],bihero[j]);
19028 }
19029 }
19030
19031 bihero_cnt = 0;
19032
19033 for(int32_t i = 0; i < NUMSCRIPTHERO; i++)
19034 if(bihero[i].first.length() > 0)
19035 bihero_cnt = i+1;
19036 }
19037
19038 //dmap scripts
19039 void build_bidmaps_list()
19040 {
19041 bidmaps[0].first = "(None)";
19042 bidmaps[0].second = -1;
19043 bidmaps_cnt = 1;
19044
19045 for(int32_t i = 0; i < NUMSCRIPTSDMAP - 1; i++)
19046 {
19047 if(dmapmap[i].scriptname.length()==0)
19048 continue;
19049
19050 stringstream ss;
19051 ss << dmapmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
19052 bidmaps[bidmaps_cnt].first = ss.str();
19053 bidmaps[bidmaps_cnt].second = i;
19054 bidmaps_cnt++;
19055 }
19056
19057 // Blank out the rest of the list
19058 for(int32_t i=bidmaps_cnt; i<NUMSCRIPTSDMAP; i++)
19059 {
19060 bidmaps[i].first="";
19061 bidmaps[i].second=-1;
19062 }
19063
19064 //Bubble sort! (doesn't account for gaps between scripts)
19065 for(int32_t i = 0; i < bidmaps_cnt - 1; i++)
19066 {
19067 for(int32_t j = i + 1; j < bidmaps_cnt; j++)
19068 {
19069 if(stricmp(bidmaps[i].first.c_str(),bidmaps[j].first.c_str()) > 0 && strcmp(bidmaps[j].first.c_str(),""))
19070 zc_swap(bidmaps[i],bidmaps[j]);
19071 }
19072 }
19073
19074 bidmaps_cnt = 0;
19075
19076 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
19077 if(bidmaps[i].first.length() > 0)
19078 bidmaps_cnt = i+1;
19079 }
19080
19081 //screen scripts
19082 void build_biscreens_list()
19083 {
19084 biscreens[0].first = "(None)";
19085 biscreens[0].second = -1;
19086 biscreens_cnt = 1;
19087
19088 for(int32_t i = 0; i < NUMSCRIPTSCREEN - 1; i++)
19089 {
19090 if(screenmap[i].scriptname.length()==0)
19091 continue;
19092
19093 stringstream ss;
19094 ss << screenmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
19095 biscreens[biscreens_cnt].first = ss.str();
19096 biscreens[biscreens_cnt].second = i;
19097 biscreens_cnt++;
19098 }
19099
19100 // Blank out the rest of the list
19101 for(int32_t i=biscreens_cnt; i<NUMSCRIPTSCREEN; i++)
19102 {
19103 biscreens[i].first="";
19104 biscreens[i].second=-1;
19105 }
19106
19107 //Bubble sort! (doesn't account for gaps between scripts)
19108 for(int32_t i = 0; i < biscreens_cnt - 1; i++)
19109 {
19110 for(int32_t j = i + 1; j < biscreens_cnt; j++)
19111 {
19112 if(stricmp(biscreens[i].first.c_str(),biscreens[j].first.c_str()) > 0 && strcmp(biscreens[j].first.c_str(),""))
19113 zc_swap(biscreens[i],biscreens[j]);
19114 }
19115 }
19116
19117 biscreens_cnt = 0;
19118
19119 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
19120 if(biscreens[i].first.length() > 0)
19121 biscreens_cnt = i+1;
19122 }
19123
19124 //screen scripts
19125 void build_biitemsprites_list()
19126 {
19127 biditemsprites[0].first = "(None)";
19128 biditemsprites[0].second = -1;
19129 biitemsprites_cnt = 1;
19130
19131 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE - 1; i++)
19132 {
19133 if(itemspritemap[i].scriptname.length()==0)
19134 continue;
19135
19136 stringstream ss;
19137 ss << itemspritemap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
19138 biditemsprites[biitemsprites_cnt].first = ss.str();
19139 biditemsprites[biitemsprites_cnt].second = i;
19140 biitemsprites_cnt++;
19141 }
19142
19143 // Blank out the rest of the list
19144 for(int32_t i=biitemsprites_cnt; i<NUMSCRIPTSITEMSPRITE; i++)
19145 {
19146 biditemsprites[i].first="";
19147 biditemsprites[i].second=-1;
19148 }
19149
19150 //Bubble sort! (doesn't account for gaps between scripts)
19151 for(int32_t i = 0; i < biitemsprites_cnt - 1; i++)
19152 {
19153 for(int32_t j = i + 1; j < biitemsprites_cnt; j++)
19154 {
19155 if(stricmp(biditemsprites[i].first.c_str(),biditemsprites[j].first.c_str()) > 0 && strcmp(biditemsprites[j].first.c_str(),""))
19156 zc_swap(biditemsprites[i],biditemsprites[j]);
19157 }
19158 }
19159
19160 biitemsprites_cnt = 0;
19161
19162 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
19163 if(biditemsprites[i].first.length() > 0)
19164 biitemsprites_cnt = i+1;
19165 }
19166
19167 6 void build_biitems_list()
19168 {
19169 6 biitems[0].first = "(None)";
19170 6 biitems[0].second = -1;
19171 6 biitems_cnt = 1;
19172
19173
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTITEM - 1; i++, biitems_cnt++)
19174 {
19175 1530 stringstream ss;
19176
19177
4/6
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 1517 times.
1530 if(!itemmap[i].isEmpty())
19178
5/10
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 13 times.
✗ Branch 9 not taken.
13 ss << itemmap[i].scriptname << " (" << i+1 << ")";
19179
19180
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 biitems[biitems_cnt].first = ss.str();
19181 1530 biitems[biitems_cnt].second = i;
19182 1530 }
19183
19184
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < biitems_cnt - 1; i++)
19185 {
19186
2/2
✓ Branch 0 taken 195840 times.
✓ Branch 1 taken 1530 times.
197370 for(int32_t j = i + 1; j < biitems_cnt; j++)
19187 {
19188
4/4
✓ Branch 0 taken 4760 times.
✓ Branch 1 taken 191080 times.
✓ Branch 2 taken 4757 times.
✓ Branch 3 taken 3 times.
195840 if(stricmp(biitems[i].first.c_str(), biitems[j].first.c_str()) > 0 && strcmp(biitems[j].first.c_str(),""))
19189 3 zc_swap(biitems[i], biitems[j]);
19190 195840 }
19191 1530 }
19192
19193 6 biitems_cnt = 0;
19194
19195
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
19196
2/2
✓ Branch 0 taken 1517 times.
✓ Branch 1 taken 19 times.
1555 if(biitems[i].first.length() > 0)
19197 19 biitems_cnt = i+1;
19198 6 }
19199
19200
19201 //dmap scripts
19202 void build_bidcomboscripts_list()
19203 {
19204 bidcomboscripts[0].first = "(None)";
19205 bidcomboscripts[0].second = -1;
19206 bidcomboscripts_cnt = 1;
19207
19208 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA - 1; i++)
19209 {
19210 if(comboscriptmap[i].scriptname.length()==0)
19211 continue;
19212
19213 stringstream ss;
19214 ss << comboscriptmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
19215 bidcomboscripts[bidcomboscripts_cnt].first = ss.str();
19216 bidcomboscripts[bidcomboscripts_cnt].second = i;
19217 bidcomboscripts_cnt++;
19218 }
19219
19220 // Blank out the rest of the list
19221 for(int32_t i=bidcomboscripts_cnt; i<NUMSCRIPTSCOMBODATA; i++)
19222 {
19223 bidcomboscripts[i].first="";
19224 bidcomboscripts[i].second=-1;
19225 }
19226
19227 //Bubble sort! (doesn't account for gaps between scripts)
19228 for(int32_t i = 0; i < bidcomboscripts_cnt - 1; i++)
19229 {
19230 for(int32_t j = i + 1; j < bidcomboscripts_cnt; j++)
19231 {
19232 if(stricmp(bidcomboscripts[i].first.c_str(),bidcomboscripts[j].first.c_str()) > 0 && strcmp(bidcomboscripts[j].first.c_str(),""))
19233 zc_swap(bidcomboscripts[i],bidcomboscripts[j]);
19234 }
19235 }
19236
19237 bidcomboscripts_cnt = 0;
19238
19239 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
19240 if(bidcomboscripts[i].first.length() > 0)
19241 bidcomboscripts_cnt = i+1;
19242 }
19243
19244
19245 const char *globalscriptlist(int32_t index, int32_t *list_size)
19246 {
19247 if(index < 0)
19248 {
19249 *list_size = biglobal_cnt;
19250 return NULL;
19251 }
19252
19253 return biglobal[index].first.c_str();
19254 }
19255
19256 const char *ffscriptlist(int32_t index, int32_t *list_size)
19257 {
19258 if(index < 0)
19259 {
19260 *list_size = biffs_cnt;
19261 return NULL;
19262 }
19263
19264 return biffs[index].first.c_str();
19265 }
19266
19267 const char *playerscriptlist(int32_t index, int32_t *list_size)
19268 {
19269 if(index < 0)
19270 {
19271 *list_size = bihero_cnt;
19272 return NULL;
19273 }
19274
19275 return bihero[index].first.c_str();
19276 }
19277
19278 const char *lweaponscriptlist(int32_t index, int32_t *list_size)
19279 {
19280 if(index < 0)
19281 {
19282 *list_size = bilweapons_cnt;
19283 return NULL;
19284 }
19285
19286 return bilweapons[index].first.c_str();
19287 }
19288
19289 const char *npcscriptlist(int32_t index, int32_t *list_size)
19290 {
19291 if(index < 0)
19292 {
19293 *list_size = binpcs_cnt;
19294 return NULL;
19295 }
19296
19297 return binpcs[index].first.c_str();
19298 }
19299
19300 static char itemscript_str_buf[32];
19301
19302 char *itemscriptlist(int32_t index, int32_t *list_size)
19303 {
19304 if(index>=0)
19305 {
19306 bound(index,0,255);
19307 sprintf(itemscript_str_buf,"%d: %s",index, ffcmap[index-1].scriptname.c_str());
19308 return itemscript_str_buf;
19309 }
19310
19311 *list_size=256;
19312 return NULL;
19313 }
19314
19315 static char ffscript_str_buf2[32];
19316
19317 const char *ffscriptlist2(int32_t index, int32_t *list_size)
19318 {
19319 if(index>=0)
19320 {
19321 char buf[20];
19322 bound(index,0,510);
19323
19324 if(ffcmap[index].scriptname=="")
19325 strcpy(buf, "<none>");
19326 else
19327 {
19328 strncpy(buf, ffcmap[index].scriptname.c_str(), 19);
19329 buf[19]='\0';
19330 }
19331
19332 sprintf(ffscript_str_buf2,"%d: %s",index+1, buf);
19333 return ffscript_str_buf2;
19334 }
19335
19336 *list_size=511;
19337 return NULL;
19338 }
19339
19340 static char itemscript_str_buf2[32];
19341
19342 const char *itemscriptlist2(int32_t index, int32_t *list_size)
19343 {
19344 if(index>=0)
19345 {
19346 char buf[20];
19347 bound(index,0,254);
19348
19349 if(itemmap[index].scriptname=="")
19350 strcpy(buf, "<none>");
19351 else
19352 {
19353 strncpy(buf, itemmap[index].scriptname.c_str(), 19);
19354 buf[19]='\0';
19355 }
19356
19357 sprintf(itemscript_str_buf2,"%d: %s",index+1, buf);
19358 return itemscript_str_buf2;
19359 }
19360
19361 *list_size=255;
19362 return NULL;
19363 }
19364
19365
19366 static char comboscript_str_buf2[32];
19367 const char *comboscriptlist2(int32_t index, int32_t *list_size)
19368 {
19369 if(index>=0)
19370 {
19371 char buf[20];
19372 bound(index,0,254);
19373
19374 if(comboscriptmap[index].scriptname=="")
19375 strcpy(buf, "<none>");
19376 else
19377 {
19378 strncpy(buf, comboscriptmap[index].scriptname.c_str(), 19);
19379 buf[19]='\0';
19380 }
19381
19382 sprintf(comboscript_str_buf2,"%d: %s",index+1, buf);
19383 return comboscript_str_buf2;
19384 }
19385
19386 *list_size=255;
19387 return NULL;
19388 }
19389
19390 static char gscript_str_buf2[40];
19391
19392 const char *gscriptlist2(int32_t index, int32_t *list_size)
19393 {
19394 if(index >= 0)
19395 {
19396 bound(index,0,3);
19397
19398 char buf[20];
19399
19400 if(globalmap[index].scriptname == "")
19401 strcpy(buf, "<none>");
19402 else
19403 {
19404 strncpy(buf, globalmap[index].scriptname.c_str(), 19);
19405 buf[19]='\0';
19406 }
19407
19408 switch(index)
19409 {
19410 case GLOBAL_SCRIPT_INIT:
19411 sprintf(gscript_str_buf2,"Initialization: %s", buf); break;
19412 case GLOBAL_SCRIPT_GAME:
19413 sprintf(gscript_str_buf2,"Active: %s", buf); break;
19414 case GLOBAL_SCRIPT_END:
19415 sprintf(gscript_str_buf2,"onExit: %s", buf); break;
19416 case GLOBAL_SCRIPT_ONSAVELOAD:
19417 sprintf(gscript_str_buf2,"onSaveLoad: %s", buf); break;
19418 case GLOBAL_SCRIPT_ONLAUNCH:
19419 sprintf(gscript_str_buf2,"onLaunch: %s", buf); break;
19420 case GLOBAL_SCRIPT_ONCONTGAME:
19421 sprintf(gscript_str_buf2,"onContGame: %s", buf); break;
19422 case GLOBAL_SCRIPT_F6:
19423 sprintf(gscript_str_buf2,"onF6Menu: %s", buf); break;
19424 case GLOBAL_SCRIPT_ONSAVE:
19425 sprintf(gscript_str_buf2,"onSave: %s", buf); break;
19426 }
19427
19428 return gscript_str_buf2;
19429 }
19430
19431 if(list_size != NULL)
19432 *list_size=4;
19433
19434 return NULL;
19435 }
19436
19437 static int32_t as_ffc_list[] = { 4, 5, 6, -1};
19438 static int32_t as_global_list[] = { 7, 8, 9, -1}; //Why does putting 15 in here not place my message only on the global tab? ~Joe
19439 static int32_t as_item_list[] = { 10, 11, 12, -1};
19440 static int32_t as_npc_list[] = { 18, 19, 20, -1}; //npc scripts TAB
19441 static int32_t as_lweapon_list[] = { 21, 22, 23, -1}; //lweapon scripts TAB
19442 static int32_t as_eweapon_list[] = { 24, 25, 26, -1}; //eweapon scripts TAB
19443 static int32_t as_hero_list[] = { 27, 28, 29, -1}; //hero scripts TAB
19444 static int32_t as_screen_list[] = { 30, 31, 32, -1}; //screendata scripts TAB
19445 static int32_t as_dmap_list[] = { 33, 34, 35, -1}; //dmapdata scripts TAB
19446 static int32_t as_itemsprite_list[] = { 36, 37, 38, -1}; //dmapdata scripts TAB
19447 static int32_t as_comboscript_list[] = { 39, 40, 41, -1}; //combodata scripts TAB
19448 static int32_t as_genericscript_list[] = { 45, 46, 47, -1}; //generic scripts TAB
19449 static int32_t as_subscreenscript_list[] = { 48, 49, 50, -1}; //generic scripts TAB
19450
19451 static TABPANEL assignscript_tabs[] =
19452 {
19453 // (text)
19454 { (char *)"FFC", D_SELECTED, as_ffc_list, 0, NULL },
19455 { (char *)"Global", 0, as_global_list, 0, NULL },
19456 { (char *)"Item", 0, as_item_list, 0, NULL },
19457 { (char *)"NPC", 0, as_npc_list, 0, NULL },
19458 { (char *)"LWeapon", 0, as_lweapon_list, 0, NULL },
19459 { (char *)"EWeapon", 0, as_eweapon_list, 0, NULL },
19460 { (char *)"Hero", 0, as_hero_list, 0, NULL },
19461 { (char *)"DMap", 0, as_dmap_list, 0, NULL },
19462 { (char *)"Screen", 0, as_screen_list, 0, NULL },
19463 { (char *)"Item Sprite", 0, as_itemsprite_list, 0, NULL },
19464 { (char *)"Combo", 0, as_comboscript_list, 0, NULL },
19465 { (char *)"Generic", 0, as_genericscript_list, 0, NULL },
19466 { (char *)"Subscreen", 0, as_subscreenscript_list, 0, NULL },
19467 { NULL, 0, NULL, 0, NULL }
19468 };
19469
19470 const char *assignffclist(int32_t index, int32_t *list_size)
19471 {
19472 if(index<0)
19473 {
19474 *list_size = (int32_t)ffcmap.size();
19475 return NULL;
19476 }
19477
19478 return ffcmap[index].output.c_str();
19479 }
19480
19481 const char *assigngloballist(int32_t index, int32_t *list_size)
19482 {
19483 if(index<0)
19484 {
19485 *list_size = (int32_t)globalmap.size();
19486 return NULL;
19487 }
19488
19489 return globalmap[index].output.c_str();
19490 }
19491
19492 const char *assigncombolist(int32_t index, int32_t *list_size)
19493 {
19494 if(index<0)
19495 {
19496 *list_size = (int32_t)comboscriptmap.size();
19497 return NULL;
19498 }
19499
19500 return comboscriptmap[index].output.c_str();
19501 }
19502
19503 const char *assigngenericlist(int32_t index, int32_t *list_size)
19504 {
19505 if(index<0)
19506 {
19507 *list_size = ((int32_t)genericmap.size());
19508 return NULL;
19509 }
19510
19511 return genericmap[index].output.c_str();
19512 }
19513
19514 const char *assignsubscreenlist(int32_t index, int32_t *list_size)
19515 {
19516 if(index<0)
19517 {
19518 *list_size = ((int32_t)subscreenmap.size());
19519 return NULL;
19520 }
19521
19522 return subscreenmap[index].output.c_str();
19523 }
19524
19525 const char *assignitemlist(int32_t index, int32_t *list_size)
19526 {
19527 if(index<0)
19528 {
19529 *list_size = (int32_t)itemmap.size();
19530 return NULL;
19531 }
19532
19533 return itemmap[index].output.c_str();
19534 }
19535 const char *assignnpclist(int32_t index, int32_t *list_size)
19536 {
19537 if(index<0)
19538 {
19539 *list_size = (int32_t)npcmap.size();
19540 return NULL;
19541 }
19542
19543 return npcmap[index].output.c_str();
19544 }
19545
19546 const char *assignlweaponlist(int32_t index, int32_t *list_size)
19547 {
19548 if(index<0)
19549 {
19550 *list_size = (int32_t)lwpnmap.size();
19551 return NULL;
19552 }
19553
19554 return lwpnmap[index].output.c_str();
19555 }
19556
19557 const char *assigneweaponlist(int32_t index, int32_t *list_size)
19558 {
19559 if(index<0)
19560 {
19561 *list_size = (int32_t)ewpnmap.size();
19562 return NULL;
19563 }
19564
19565 return ewpnmap[index].output.c_str();
19566 }
19567
19568 const char *assignplayerlist(int32_t index, int32_t *list_size)
19569 {
19570 if(index<0)
19571 {
19572 *list_size = (int32_t)playermap.size();
19573 return NULL;
19574 }
19575
19576 return playermap[index].output.c_str();
19577 }
19578
19579 const char *assigndmaplist(int32_t index, int32_t *list_size)
19580 {
19581 if(index<0)
19582 {
19583 *list_size = (int32_t)dmapmap.size();
19584 return NULL;
19585 }
19586
19587 return dmapmap[index].output.c_str();
19588 }
19589
19590 const char *assignscreenlist(int32_t index, int32_t *list_size)
19591 {
19592 if(index<0)
19593 {
19594 *list_size = (int32_t)screenmap.size();
19595 return NULL;
19596 }
19597
19598 return screenmap[index].output.c_str();
19599 }
19600
19601 const char *assignitemspritelist(int32_t index, int32_t *list_size)
19602 {
19603 if(index<0)
19604 {
19605 *list_size = (int32_t)itemspritemap.size();
19606 return NULL;
19607 }
19608
19609 return itemspritemap[index].output.c_str();
19610 }
19611
19612 const char *assignffcscriptlist(int32_t index, int32_t *list_size)
19613 {
19614 if(index<0)
19615 {
19616 *list_size = (int32_t)asffcscripts.size();
19617 return NULL;
19618 }
19619
19620 return asffcscripts[index].c_str();
19621 }
19622
19623 const char *assignglobalscriptlist(int32_t index, int32_t *list_size)
19624 {
19625 if(index<0)
19626 {
19627 *list_size = (int32_t)asglobalscripts.size();
19628 return NULL;
19629 }
19630
19631 return asglobalscripts[index].c_str();
19632 }
19633
19634 const char *assignitemscriptlist(int32_t index, int32_t *list_size)
19635 {
19636 if(index<0)
19637 {
19638 *list_size = (int32_t)asitemscripts.size();
19639 return NULL;
19640 }
19641
19642 return asitemscripts[index].c_str();
19643 }
19644
19645 const char *assignnpcscriptlist(int32_t index, int32_t *list_size)
19646 {
19647 if(index<0)
19648 {
19649 *list_size = (int32_t)asnpcscripts.size();
19650 return NULL;
19651 }
19652
19653 return asnpcscripts[index].c_str();
19654 }
19655
19656 const char *assignlweaponscriptlist(int32_t index, int32_t *list_size)
19657 {
19658 if(index<0)
19659 {
19660 *list_size = (int32_t)aslweaponscripts.size();
19661 return NULL;
19662 }
19663
19664 return aslweaponscripts[index].c_str();
19665 }
19666
19667 const char *assigneweaponscriptlist(int32_t index, int32_t *list_size)
19668 {
19669 if(index<0)
19670 {
19671 *list_size = (int32_t)aseweaponscripts.size();
19672 return NULL;
19673 }
19674
19675 return aseweaponscripts[index].c_str();
19676 }
19677
19678 const char *assignplayerscriptlist(int32_t index, int32_t *list_size)
19679 {
19680 if(index<0)
19681 {
19682 *list_size = (int32_t)asplayerscripts.size();
19683 return NULL;
19684 }
19685
19686 return asplayerscripts[index].c_str();
19687 }
19688
19689 const char *assigndmapscriptlist(int32_t index, int32_t *list_size)
19690 {
19691 if(index<0)
19692 {
19693 *list_size = (int32_t)asdmapscripts.size();
19694 return NULL;
19695 }
19696
19697 return asdmapscripts[index].c_str();
19698 }
19699
19700 const char *assignscreenscriptlist(int32_t index, int32_t *list_size)
19701 {
19702 if(index<0)
19703 {
19704 *list_size = (int32_t)asscreenscripts.size();
19705 return NULL;
19706 }
19707
19708 return asscreenscripts[index].c_str();
19709 }
19710
19711 const char *assignitemspritescriptlist(int32_t index, int32_t *list_size)
19712 {
19713 if(index<0)
19714 {
19715 *list_size = (int32_t)asitemspritescripts.size();
19716 return NULL;
19717 }
19718
19719 return asitemspritescripts[index].c_str();
19720 }
19721
19722 const char *assigncomboscriptlist(int32_t index, int32_t *list_size)
19723 {
19724 if(index<0)
19725 {
19726 *list_size = (int32_t)ascomboscripts.size();
19727 return NULL;
19728 }
19729
19730 return ascomboscripts[index].c_str();
19731 }
19732
19733 const char *assigngenericscriptlist(int32_t index, int32_t *list_size)
19734 {
19735 if(index<0)
19736 {
19737 *list_size = (int32_t)asgenericscripts.size();
19738 return NULL;
19739 }
19740
19741 return asgenericscripts[index].c_str();
19742 }
19743
19744 const char *assignsubscreenscriptlist(int32_t index, int32_t *list_size)
19745 {
19746 if(index<0)
19747 {
19748 *list_size = (int32_t)assubscreenscripts.size();
19749 return NULL;
19750 }
19751
19752 return assubscreenscripts[index].c_str();
19753 }
19754
19755 12 static ListData assignffc_list(assignffclist, &font);
19756 12 static ListData assignffcscript_list(assignffcscriptlist, &font);
19757 12 static ListData assignglobal_list(assigngloballist, &font);
19758 12 static ListData assignglobalscript_list(assignglobalscriptlist, &font);
19759 12 static ListData assignitem_list(assignitemlist, &font);
19760 12 static ListData assignitemscript_list(assignitemscriptlist, &font);
19761 12 static ListData assignnpc_list(assignnpclist, &font);
19762 12 static ListData assignnpcscript_list(assignnpcscriptlist, &font);
19763 12 static ListData assignlweapon_list(assignlweaponlist, &font);
19764 12 static ListData assignlweaponscript_list(assignlweaponscriptlist, &font);
19765 12 static ListData assigneweapon_list(assigneweaponlist, &font);
19766 12 static ListData assigneweaponscript_list(assigneweaponscriptlist, &font);
19767
19768 12 static ListData assignplayer_list(assignplayerlist, &font);
19769 12 static ListData assignplayerscript_list(assignplayerscriptlist, &font);
19770
19771 12 static ListData assigndmap_list(assigndmaplist, &font);
19772 12 static ListData assigndmapscript_list(assigndmapscriptlist, &font);
19773
19774 12 static ListData assignscreen_list(assignscreenlist, &font);
19775 12 static ListData assignscreenscript_list(assignscreenscriptlist, &font);
19776
19777 12 static ListData assignitemsprite_list(assignitemspritelist, &font);
19778 12 static ListData assignitemspritescript_list(assignitemspritescriptlist, &font);
19779
19780 12 static ListData assigncombo_list(assigncombolist, &font);
19781 12 static ListData assigncomboscript_list(assigncomboscriptlist, &font);
19782
19783 12 static ListData assigngeneric_list(assigngenericlist, &font);
19784 12 static ListData assigngenericscript_list(assigngenericscriptlist, &font);
19785
19786 12 static ListData assignsubscreen_list(assignsubscreenlist, &font);
19787 12 static ListData assignsubscreenscript_list(assignsubscreenscriptlist, &font);
19788
19789 static DIALOG assignscript_dlg[] =
19790 {
19791 // x y w h fg bg key flags d1 d2 dp
19792 12 { jwin_win_proc, 0, 0, 330, 236, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Assign Compiled Script", NULL, NULL },
19793 12 { jwin_tab_proc, 6, 25, 330-12, 130, 0, 0, 0, 0, 0, 0, assignscript_tabs, NULL, (void*)assignscript_dlg },
19794 12 { jwin_button_proc, 251, 207, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
19795 12 { jwin_button_proc, 182, 207, 61, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
19796 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignffc_list, NULL, NULL },
19797 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignffcscript_list, NULL, NULL },
19798 //6
19799 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19800 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignglobal_list, NULL, NULL },
19801 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignglobalscript_list, NULL, NULL },
19802 //9
19803 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19804 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitem_list, NULL, NULL },
19805 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitemscript_list, NULL, NULL },
19806 //12
19807 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19808 //13
19809 12 { jwin_check_proc, 22, 211, 90, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Output ZASM code to allegro.log", NULL, NULL },
19810 12 { jwin_text_proc, 22, 178, 90, 24, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
19811 12 { d_dummy_proc, 0, 0, 0, 0, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
19812 //16
19813 12 { d_dummy_proc, 0, 0, 0, 0, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
19814 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19815 //npc scripts
19816 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignnpc_list, NULL, NULL },
19817 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignnpcscript_list, NULL, NULL },
19818 //20
19819 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19820 //21
19821 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignlweapon_list, NULL, NULL },
19822 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignlweaponscript_list, NULL, NULL },
19823 //23
19824 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19825 //24
19826 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigneweapon_list, NULL, NULL },
19827 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigneweaponscript_list, NULL, NULL },
19828 //26
19829 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19830 //27
19831 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignplayer_list, NULL, NULL },
19832 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignplayerscript_list, NULL, NULL },
19833 //29
19834 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19835 //30
19836 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignscreen_list, NULL, NULL },
19837 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignscreenscript_list, NULL, NULL },
19838 //32
19839 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19840 //33
19841 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigndmap_list, NULL, NULL },
19842 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigndmapscript_list, NULL, NULL },
19843 //35
19844 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19845 //36
19846 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitemsprite_list, NULL, NULL },
19847 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitemspritescript_list, NULL, NULL },
19848 //38
19849 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19850
19851 //39
19852 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigncombo_list, NULL, NULL },
19853 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigncomboscript_list, NULL, NULL },
19854 //41
19855 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19856 12 { jwin_button_proc, 78-24, 158, 48, 16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Script Info", NULL, NULL },
19857 12 { jwin_button_proc, 174+78-24, 158, 48, 16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Script Info", NULL, NULL },
19858 12 { jwin_button_proc, 87+78-24, 158, 48, 16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Clear", NULL, NULL },
19859 //45
19860 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigngeneric_list, NULL, NULL },
19861 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigngenericscript_list, NULL, NULL },
19862 //47
19863 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19864 //48
19865 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignsubscreen_list, NULL, NULL },
19866 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignsubscreenscript_list, NULL, NULL },
19867 //50
19868 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19869 12 { jwin_check_proc, 22, 221, 90, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "...And output ZASM comments", NULL, NULL },
19870
19871 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
19872
19873 };
19874
19875 int32_t txtout(BITMAP* dest, const char* txt, int32_t x, int32_t y, bool disabled)
19876 {
19877 if(disabled)
19878 {
19879 gui_textout_ln(dest, font, (uint8_t*)txt, x+1, y+1, scheme[jcLIGHT], scheme[jcBOX], 0);
19880 return gui_textout_ln(dest, font, (uint8_t*)txt, x, y, scheme[jcMEDDARK], -1, 0);
19881 }
19882 else
19883 {
19884 return gui_textout_ln(dest, font, (uint8_t*)txt, x, y, scheme[jcBOXFG], scheme[jcBOX], 0);
19885 }
19886 }
19887
19888 int32_t jwin_zmeta_proc(int32_t msg, DIALOG *d, int32_t )
19889 {
19890 int32_t ret = D_O_K;
19891 ASSERT(d);
19892
19893 BITMAP* target = (msg==MSG_START ? NULL : screen);
19894 switch(msg)
19895 {
19896 case MSG_START:
19897 case MSG_DRAW:
19898 {
19899 FONT *oldfont = font;
19900
19901 if(d->dp2)
19902 {
19903 font = (FONT*)d->dp2;
19904 }
19905
19906 bool disabled = (d->flags & D_DISABLED) != 0;
19907 if(d->dp)
19908 {
19909 zasm_meta const& meta = *((zasm_meta*)d->dp);
19910 int32_t ind = -1;
19911 d->w = 0;
19912 if(!meta.valid())
19913 {
19914 d->w = txtout(target, "Invalid ZASM metadata found!", d->x, d->y, disabled);
19915 ++ind;
19916 }
19917
19918 int32_t t_w = 0;
19919 char buf[1024];
19920 memset(buf, 0, sizeof(buf));
19921 sprintf(buf, "ZASM Version: %d", meta.zasm_v);
19922 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19923 d->w = zc_max(d->w, t_w);
19924 memset(buf, 0, sizeof(buf));
19925 sprintf(buf, "Metadata Version: %d", meta.meta_v);
19926 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19927 d->w = zc_max(d->w, t_w);
19928 memset(buf, 0, sizeof(buf));
19929 sprintf(buf, "FFScript Version: %d", meta.ffscript_v);
19930 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19931 d->w = zc_max(d->w, t_w);
19932 memset(buf, 0, sizeof(buf));
19933 sprintf(buf, "Script Name: %s", meta.script_name.c_str());
19934 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19935 d->w = zc_max(d->w, t_w);
19936 memset(buf, 0, sizeof(buf));
19937 sprintf(buf, "Author: %s", meta.author.c_str());
19938 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19939 d->w = zc_max(d->w, t_w);
19940 memset(buf, 0, sizeof(buf));
19941 sprintf(buf, "Script Type: %s", get_script_name(meta.script_type).c_str());
19942 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19943 d->w = zc_max(d->w, t_w);
19944 for(auto q = 0; q < 4; ++q)
19945 {
19946 if(!meta.attributes[q].size())
19947 continue;
19948 memset(buf, 0, sizeof(buf));
19949 sprintf(buf, "Attributes[%d]: %s", q, meta.attributes[q].c_str());
19950 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19951 d->w = zc_max(d->w, t_w);
19952 }
19953 for(auto q = 0; q < 8; ++q)
19954 {
19955 if(!meta.attribytes[q].size())
19956 continue;
19957 memset(buf, 0, sizeof(buf));
19958 sprintf(buf, "Attribytes[%d]: %s", q, meta.attribytes[q].c_str());
19959 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19960 d->w = zc_max(d->w, t_w);
19961 }
19962 for(auto q = 0; q < 8; ++q)
19963 {
19964 if(!meta.attrishorts[q].size())
19965 continue;
19966 memset(buf, 0, sizeof(buf));
19967 sprintf(buf, "Attrishorts[%d]: %s", q, meta.attrishorts[q].c_str());
19968 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19969 d->w = zc_max(d->w, t_w);
19970 }
19971 bool indentrun = false;
19972 int32_t run_indent = txtout(NULL, "void run(", 0, 0, false);
19973 std::ostringstream oss;
19974 oss << "void run(";
19975 for(int32_t q = 0; q < 8; ++q)
19976 {
19977 if(!meta.run_idens[q].size() || meta.run_types[q] == ZMETA_NULL_TYPE) continue;
19978 if(q > 0)
19979 oss << ", ";
19980 string type_name = ZScript::getDataTypeName(meta.run_types[q]);
19981 lowerstr(type_name); //all lowercase for this output
19982 if(oss.str().size() > unsigned(indentrun ? 41 : 50))
19983 {
19984 memset(buf, 0, sizeof(buf));
19985 sprintf(buf, "%s", oss.str().c_str());
19986 t_w = txtout(target, buf, d->x + (indentrun ? run_indent : 0), d->y + ((++ind)*(text_height(font) + 3)), disabled) + (indentrun ? run_indent : 0);
19987 d->w = zc_max(d->w, t_w);
19988 oss.str("");
19989 indentrun = true;
19990 }
19991 oss << type_name.c_str() << " " << meta.run_idens[q];
19992 }
19993 oss << ");";
19994 memset(buf, 0, sizeof(buf));
19995 sprintf(buf, "%s", oss.str().c_str());
19996 t_w = txtout(target, buf, d->x + (indentrun ? run_indent : 0), d->y + ((++ind)*(text_height(font) + 3)), disabled) + (indentrun ? run_indent : 0);
19997 d->w = zc_max(d->w, t_w);
19998 memset(buf, 0, sizeof(buf));
19999 sprintf(buf, "Compiler Version: %d.%d.%d.%d", meta.compiler_v1, meta.compiler_v2, meta.compiler_v3, meta.compiler_v4);
20000 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
20001 d->w = zc_max(d->w, t_w);
20002 memset(buf, 0, sizeof(buf));
20003 sprintf(buf, "Parser-generated: %s", (meta.flags & ZMETA_AUTOGEN)!=0 ? "TRUE" : "FALSE");
20004 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
20005 d->w = zc_max(d->w, t_w);
20006 d->h = (++ind) * (text_height(font) + 3) -3;
20007 }
20008 else
20009 {
20010 d->w = txtout(target, "No ZASM metadata found!", d->x, d->y, disabled);
20011 d->h = text_height(font);
20012 }
20013
20014 if(d->dp3) //function trigger
20015 {
20016 typedef void (*funcType)(void);
20017 funcType func=reinterpret_cast<funcType>(d->dp3);
20018 func();
20019 }
20020
20021 font = oldfont;
20022 break;
20023 }
20024 }
20025
20026 return ret;
20027 }
20028
20029 void resize_scriptinfo_dlg();
20030
20031 static DIALOG scriptinfo_dlg[] =
20032 {
20033 // x y w h fg bg key flags d1 d2 dp
20034 { jwin_win_proc, 0, 0, 200, 150, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Script Metadata", NULL, NULL },
20035 { d_dummy_proc, 6, 25, 330-12, 130, 0, 0, 0, 0, 0, 0, assignscript_tabs, NULL, NULL },
20036 { jwin_button_proc, 70, 120, 60, 20, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
20037 { jwin_zmeta_proc, 50, 30, 100, 100, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, (void*)resize_scriptinfo_dlg },
20038
20039 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
20040 };
20041
20042 void resize_scriptinfo_dlg()
20043 {
20044 DIALOG *meta_proc = &scriptinfo_dlg[3], *window = &scriptinfo_dlg[0], *ok_button = &scriptinfo_dlg[2];
20045 int32_t bmargin = 15, hmargins = 30;
20046 jwin_ulalign_dialog(scriptinfo_dlg);
20047 window->w = hmargins*2 + meta_proc->w;
20048 meta_proc->x = hmargins;
20049 window->h = meta_proc->y + meta_proc->h + ok_button->h + bmargin*2;
20050 ok_button->x = (window->w/2)-(ok_button->w/2);
20051 ok_button->y = meta_proc->y + meta_proc->h + bmargin;
20052 jwin_center_dialog(scriptinfo_dlg);
20053 }
20054
20055 void showScriptInfo(zasm_meta const* meta)
20056 {
20057 scriptinfo_dlg[3].dp = (void*)meta;
20058 scriptinfo_dlg[0].dp2 = get_zc_font(font_lfont);
20059 large_dialog(scriptinfo_dlg);
20060 jwin_zmeta_proc(MSG_START,&scriptinfo_dlg[3],0); //Calculate size before calling dialog
20061 jwin_center_dialog(scriptinfo_dlg);
20062 do_zqdialog(scriptinfo_dlg,2);
20063 }
20064
20065 void write_includepaths();
20066 void call_compile_settings();
20067 int32_t onZScriptCompilerSettings()
20068 {
20069 call_compile_settings();
20070 return D_O_K;
20071 }
20072
20073 void doEditZScript()
20074 {
20075 if(do_box_edit(zScript, "ZScript Buffer", false, false))
20076 saved=false;
20077 }
20078
20079 std::string qst_cfg_header_from_path(std::string path);
20080 extern char *filepath;
20081 string get_box_cfg_hdr(int num)
20082 {
20083 if(num)
20084 return "misc";
20085 return qst_cfg_header_from_path(filepath);
20086 }
20087
20088 //{ Start type-specific import dlgs
20089 12 static ListData ffscript_sel_dlg_list(ffscriptlist2, &font);
20090 12 static ListData itemscript_sel_dlg_list(itemscriptlist2, &font);
20091 12 static ListData comboscript_sel_dlg_list(comboscriptlist2, &font);
20092 12 static ListData gscript_sel_dlg_list(gscriptlist2, &font);
20093 static char npcscript_str_buf2[32];
20094 const char *npcscriptlist2(int32_t index, int32_t *list_size)
20095 {
20096 if(index>=0)
20097 {
20098 char buf[20];
20099 bound(index,0,254);
20100
20101 if(npcmap[index].scriptname=="")
20102 strcpy(buf, "<none>");
20103 else
20104 {
20105 strncpy(buf, npcmap[index].scriptname.c_str(), 19);
20106 buf[19]='\0';
20107 }
20108
20109 sprintf(npcscript_str_buf2,"%d: %s",index+1, buf);
20110 return npcscript_str_buf2;
20111 }
20112
20113 *list_size=(NUMSCRIPTGUYS-1);
20114 return NULL;
20115 }
20116 12 static ListData npcscript_sel_dlg_list(npcscriptlist2, &font);
20117 static char lweaponscript_str_buf2[32];
20118 const char *lweaponscriptlist2(int32_t index, int32_t *list_size)
20119 {
20120 if(index>=0)
20121 {
20122 char buf[20];
20123 bound(index,0,254);
20124
20125 if(lwpnmap[index].scriptname=="")
20126 strcpy(buf, "<none>");
20127 else
20128 {
20129 strncpy(buf, lwpnmap[index].scriptname.c_str(), 19);
20130 buf[19]='\0';
20131 }
20132
20133 sprintf(lweaponscript_str_buf2,"%d: %s",index+1, buf);
20134 return lweaponscript_str_buf2;
20135 }
20136
20137 *list_size=(NUMSCRIPTWEAPONS-1);
20138 return NULL;
20139 }
20140 12 static ListData lweaponscript_sel_dlg_list(lweaponscriptlist2, &font);
20141 static char eweaponscript_str_buf2[32];
20142 const char *eweaponscriptlist2(int32_t index, int32_t *list_size)
20143 {
20144 if(index>=0)
20145 {
20146 char buf[20];
20147 bound(index,0,254);
20148
20149 if(ewpnmap[index].scriptname=="")
20150 strcpy(buf, "<none>");
20151 else
20152 {
20153 strncpy(buf, ewpnmap[index].scriptname.c_str(), 19);
20154 buf[19]='\0';
20155 }
20156
20157 sprintf(eweaponscript_str_buf2,"%d: %s",index+1, buf);
20158 return eweaponscript_str_buf2;
20159 }
20160
20161 *list_size=(NUMSCRIPTWEAPONS-1);
20162 return NULL;
20163 }
20164 12 static ListData eweaponscript_sel_dlg_list(eweaponscriptlist2, &font);
20165 static char playerscript_str_buf2[32];
20166 const char *playerscriptlist2(int32_t index, int32_t *list_size)
20167 {
20168 if(index>=0)
20169 {
20170 char buf[20];
20171 bound(index,0,3);
20172
20173 if(playermap[index].scriptname=="")
20174 strcpy(buf, "<none>");
20175 else
20176 {
20177 strncpy(buf, playermap[index].scriptname.c_str(), 19);
20178 buf[19]='\0';
20179 }
20180
20181 if(index==0)
20182 sprintf(playerscript_str_buf2,"Init: %s", buf);
20183
20184 if(index==1)
20185 sprintf(playerscript_str_buf2,"Active: %s", buf);
20186
20187 if(index==2)
20188 sprintf(playerscript_str_buf2,"Death: %s", buf);
20189
20190
20191 //sprintf(playerscript_str_buf2,"%d: %s",index+1, buf);
20192 return playerscript_str_buf2;
20193 }
20194
20195 *list_size=(NUMSCRIPTHERO-1);
20196 return NULL;
20197 }
20198 static char itemspritescript_str_buf2[32];
20199 const char *itemspritescriptlist2(int32_t index, int32_t *list_size)
20200 {
20201 if(index>=0)
20202 {
20203 char buf[20];
20204 bound(index,0,254);
20205
20206 if(itemspritemap[index].scriptname=="")
20207 strcpy(buf, "<none>");
20208 else
20209 {
20210 strncpy(buf, itemspritemap[index].scriptname.c_str(), 19);
20211 buf[19]='\0';
20212 }
20213
20214 sprintf(itemspritescript_str_buf2,"%d: %s",index+1, buf);
20215 return itemspritescript_str_buf2;
20216 }
20217
20218 *list_size=(NUMSCRIPTSITEMSPRITE-1);
20219 return NULL;
20220 }
20221 12 static ListData playerscript_sel_dlg_list(playerscriptlist2, &font);
20222 static char dmapscript_str_buf2[32];
20223 const char *dmapscriptlist2(int32_t index, int32_t *list_size)
20224 {
20225 if(index>=0)
20226 {
20227 char buf[20];
20228 bound(index,0,254);
20229
20230 if(dmapmap[index].scriptname=="")
20231 strcpy(buf, "<none>");
20232 else
20233 {
20234 strncpy(buf, dmapmap[index].scriptname.c_str(), 19);
20235 buf[19]='\0';
20236 }
20237
20238 sprintf(dmapscript_str_buf2,"%d: %s",index+1, buf);
20239 return dmapscript_str_buf2;
20240 }
20241
20242 *list_size=(NUMSCRIPTSDMAP-1);
20243 return NULL;
20244 }
20245 12 static ListData dmapscript_sel_dlg_list(dmapscriptlist2, &font);
20246 12 static ListData itemspritescript_sel_dlg_list(itemspritescriptlist2, &font);
20247 static char screenscript_str_buf2[32];
20248 const char *screenscriptlist2(int32_t index, int32_t *list_size)
20249 {
20250 if(index>=0)
20251 {
20252 char buf[20];
20253 bound(index,0,254);
20254
20255 if(screenmap[index].scriptname=="")
20256 strcpy(buf, "<none>");
20257 else
20258 {
20259 strncpy(buf, screenmap[index].scriptname.c_str(), 19);
20260 buf[19]='\0';
20261 }
20262
20263 sprintf(screenscript_str_buf2,"%d: %s",index+1, buf);
20264 return screenscript_str_buf2;
20265 }
20266
20267 *list_size=(NUMSCRIPTSCREEN-1);
20268 return NULL;
20269 }
20270 12 static ListData screenscript_sel_dlg_list(screenscriptlist2, &font);
20271 //} End type-specific import dlgs
20272
20273 6 void clear_map_states()
20274 {
20275
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(map<int32_t, script_slot_data>::iterator it = ffcmap.begin();
20276 3072 it != ffcmap.end(); ++it)
20277 {
20278 3066 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20279 3066 }
20280
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 6 times.
54 for(map<int32_t, script_slot_data>::iterator it = globalmap.begin();
20281 54 it != globalmap.end(); ++it)
20282 {
20283 48 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20284 48 }
20285
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = itemmap.begin();
20286 1536 it != itemmap.end(); ++it)
20287 {
20288 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20289 1530 }
20290
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = npcmap.begin();
20291 1536 it != npcmap.end(); ++it)
20292 {
20293 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20294 1530 }
20295
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = ewpnmap.begin();
20296 1536 it != ewpnmap.end(); ++it)
20297 {
20298 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20299 1530 }
20300
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = lwpnmap.begin();
20301 1536 it != lwpnmap.end(); ++it)
20302 {
20303 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20304 1530 }
20305
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
30 for(map<int32_t, script_slot_data>::iterator it = playermap.begin();
20306 30 it != playermap.end(); ++it)
20307 {
20308 24 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20309 24 }
20310
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = dmapmap.begin();
20311 1536 it != dmapmap.end(); ++it)
20312 {
20313 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20314 1530 }
20315
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = screenmap.begin();
20316 1536 it != screenmap.end(); ++it)
20317 {
20318 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20319 1530 }
20320
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = itemspritemap.begin();
20321 1536 it != itemspritemap.end(); ++it)
20322 {
20323 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20324 1530 }
20325
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(map<int32_t, script_slot_data>::iterator it = comboscriptmap.begin();
20326 3072 it != comboscriptmap.end(); ++it)
20327 {
20328 3066 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20329 3066 }
20330 6 }
20331
20332 void clearAssignSlotDlg()
20333 {
20334 assignscript_dlg[0].dp2 = get_zc_font(font_lfont);
20335 assignscript_dlg[4].d1 = -1;
20336 assignscript_dlg[5].d1 = -1;
20337 assignscript_dlg[7].d1 = -1;
20338 assignscript_dlg[8].d1 = -1;
20339 assignscript_dlg[10].d1 = -1;
20340 assignscript_dlg[11].d1 = -1;
20341 assignscript_dlg[13].flags = 0;
20342 }
20343
20344 void inc_script_name(string& name)
20345 {
20346 size_t pos = name.find_last_not_of("0123456789");
20347 pos = name.find_first_of("0123456789",pos);
20348 std::ostringstream oss;
20349 if(pos == string::npos)
20350 {
20351 oss << name << 2;
20352 }
20353 else
20354 {
20355 int32_t val = atoi(name.substr(pos).c_str());
20356 oss << name.substr(0,pos) << val+1;
20357 }
20358 name = oss.str();
20359 }
20360
20361 enum script_slot_type
20362 {
20363 type_ffc, type_global, type_itemdata, type_npc, type_lweapon, type_eweapon,
20364 type_hero, type_dmap, type_screen, type_itemsprite, type_combo, type_generic,
20365 type_subscreen, num_types
20366 };
20367 script_slot_type getType(ScriptType type)
20368 {
20369 switch(type)
20370 {
20371 case ScriptType::FFC: return type_ffc;
20372 case ScriptType::Global: return type_global;
20373 case ScriptType::Item: return type_itemdata;
20374 case ScriptType::NPC: return type_npc;
20375 case ScriptType::Lwpn: return type_lweapon;
20376 case ScriptType::Ewpn: return type_eweapon;
20377 case ScriptType::Hero: return type_hero;
20378 case ScriptType::DMap:
20379 case ScriptType::ScriptedActiveSubscreen:
20380 case ScriptType::ScriptedPassiveSubscreen:
20381 case ScriptType::OnMap:
20382 return type_dmap;
20383 case ScriptType::Generic: case ScriptType::GenericFrozen:
20384 return type_generic;
20385 case ScriptType::Screen: return type_screen;
20386 case ScriptType::ItemSprite: return type_itemsprite;
20387 case ScriptType::Combo: return type_combo;
20388 case ScriptType::EngineSubscreen: return type_subscreen;
20389 default: return type_ffc; //Default
20390 }
20391 }
20392 #define SLOTMSGFLAG_MISSING 0x01
20393 #define SLOTMSG_SIZE 512
20394 bool checkSkip(int32_t format, byte flags)
20395 {
20396 switch(format)
20397 {
20398 case SCRIPT_FORMAT_DEFAULT:
20399 return (flags != 0);
20400 case SCRIPT_FORMAT_INVALID:
20401 return ((flags & SLOTMSGFLAG_MISSING)==0);
20402 default: return true;
20403 }
20404 }
20405 void clearAllSlots(int32_t type, byte flags = 0)
20406 {
20407 bound(type,0,num_types-1);
20408 switch(type)
20409 {
20410 case type_ffc:
20411 {
20412 for(int32_t q = 0; q < NUMSCRIPTFFC-1; ++q)
20413 {
20414 if(checkSkip(ffcmap[q].format, flags)) continue;
20415 ffcmap[q].scriptname = "";
20416 ffcmap[q].format = SCRIPT_FORMAT_DEFAULT;
20417 }
20418 break;
20419 }
20420 case type_global:
20421 {
20422 //Start at 1 to not clear Init
20423 for(int32_t q = 1; q < NUMSCRIPTGLOBAL; ++q)
20424 {
20425 if(checkSkip(globalmap[q].format, flags)) continue;
20426 globalmap[q].scriptname = "";
20427 globalmap[q].format = SCRIPT_FORMAT_DEFAULT;
20428 }
20429 break;
20430 }
20431 case type_itemdata:
20432 {
20433 for(int32_t q = 0; q < NUMSCRIPTITEM-1; ++q)
20434 {
20435 if(checkSkip(itemmap[q].format, flags)) continue;
20436 itemmap[q].scriptname = "";
20437 itemmap[q].format = SCRIPT_FORMAT_DEFAULT;
20438 }
20439 break;
20440 }
20441 case type_npc:
20442 {
20443 for(int32_t q = 0; q < NUMSCRIPTGUYS-1; ++q)
20444 {
20445 if(checkSkip(npcmap[q].format, flags)) continue;
20446 npcmap[q].scriptname = "";
20447 npcmap[q].format = SCRIPT_FORMAT_DEFAULT;
20448 }
20449 break;
20450 }
20451 case type_lweapon:
20452 {
20453 for(int32_t q = 0; q < NUMSCRIPTWEAPONS-1; ++q)
20454 {
20455 if(checkSkip(lwpnmap[q].format, flags)) continue;
20456 lwpnmap[q].scriptname = "";
20457 lwpnmap[q].format = SCRIPT_FORMAT_DEFAULT;
20458 }
20459 break;
20460 }
20461 case type_eweapon:
20462 {
20463 for(int32_t q = 0; q < NUMSCRIPTWEAPONS-1; ++q)
20464 {
20465 if(checkSkip(ewpnmap[q].format, flags)) continue;
20466 ewpnmap[q].scriptname = "";
20467 ewpnmap[q].format = SCRIPT_FORMAT_DEFAULT;
20468 }
20469 break;
20470 }
20471 case type_hero:
20472 {
20473 for(int32_t q = 0; q < NUMSCRIPTHERO-1; ++q)
20474 {
20475 if(checkSkip(playermap[q].format, flags)) continue;
20476 playermap[q].scriptname = "";
20477 playermap[q].format = SCRIPT_FORMAT_DEFAULT;
20478 }
20479 break;
20480 }
20481 case type_dmap:
20482 {
20483 for(int32_t q = 0; q < NUMSCRIPTSDMAP-1; ++q)
20484 {
20485 if(checkSkip(dmapmap[q].format, flags)) continue;
20486 dmapmap[q].scriptname = "";
20487 dmapmap[q].format = SCRIPT_FORMAT_DEFAULT;
20488 }
20489 break;
20490 }
20491 case type_screen:
20492 {
20493 for(int32_t q = 0; q < NUMSCRIPTSCREEN-1; ++q)
20494 {
20495 if(checkSkip(screenmap[q].format, flags)) continue;
20496 screenmap[q].scriptname = "";
20497 screenmap[q].format = SCRIPT_FORMAT_DEFAULT;
20498 }
20499 break;
20500 }
20501 case type_itemsprite:
20502 {
20503 for(int32_t q = 0; q < NUMSCRIPTSITEMSPRITE-1; ++q)
20504 {
20505 if(checkSkip(itemspritemap[q].format, flags)) continue;
20506 itemspritemap[q].scriptname = "";
20507 itemspritemap[q].format = SCRIPT_FORMAT_DEFAULT;
20508 }
20509 break;
20510 }
20511 case type_combo:
20512 {
20513 for(int32_t q = 0; q < NUMSCRIPTSCOMBODATA-1; ++q)
20514 {
20515 if(checkSkip(comboscriptmap[q].format, flags)) continue;
20516 comboscriptmap[q].scriptname = "";
20517 comboscriptmap[q].format = SCRIPT_FORMAT_DEFAULT;
20518 }
20519 break;
20520 }
20521 case type_generic:
20522 {
20523 for(int32_t q = 0; q < NUMSCRIPTSGENERIC-1; ++q)
20524 {
20525 if(checkSkip(genericmap[q].format, flags)) continue;
20526 genericmap[q].scriptname = "";
20527 genericmap[q].format = SCRIPT_FORMAT_DEFAULT;
20528 }
20529 break;
20530 }
20531 case type_subscreen:
20532 {
20533 for(int32_t q = 0; q < NUMSCRIPTSSUBSCREEN-1; ++q)
20534 {
20535 if(checkSkip(subscreenmap[q].format, flags)) continue;
20536 subscreenmap[q].scriptname = "";
20537 subscreenmap[q].format = SCRIPT_FORMAT_DEFAULT;
20538 }
20539 break;
20540 }
20541 }
20542 }
20543
20544 static bool doslots_log_output = false, doslots_comment_output = true;
20545 6 void setup_scriptslot_dlg(char* buf, byte flags)
20546 {
20547 //{ Set up the textbox at the bottom, and auto-resize height based on it
20548 6 int32_t prev_height = assignscript_dlg[14].h;
20549 6 memset(buf, 0, SLOTMSG_SIZE);
20550 //
20551 6 strcpy(buf, "Slots with matching names have been updated.\n");
20552
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if(flags & SLOTMSGFLAG_MISSING)
20553 3 strcat(buf,"Scripts prefixed with '--' were not found, and will not function.\n");
20554 6 strcat(buf,"Global scripts named 'Init' will be appended to '~Init'");
20555 //
20556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 SETFLAG(assignscript_dlg[13].flags, D_SELECTED, doslots_log_output);
20557
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 SETFLAG(assignscript_dlg[51].flags, D_SELECTED, doslots_comment_output);
20558 6 assignscript_dlg[14].dp = buf;
20559 6 object_message(&assignscript_dlg[14], MSG_START, 0); //Set the width/height
20560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(int32_t diff = assignscript_dlg[14].h - prev_height) //resize dlg
20561 {
20562 6 int32_t prev_bottom = assignscript_dlg[14].y + prev_height;
20563
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 6 times.
312 for(int32_t q = 1; assignscript_dlg[q].proc; ++q)
20564 {
20565
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 300 times.
306 if(q==14) continue; //Don't change self
20566
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 24 times.
300 if(assignscript_dlg[q].y < prev_bottom) continue; //above proc
20567 24 assignscript_dlg[q].y += diff;
20568 24 }
20569 6 assignscript_dlg[0].h += diff;
20570 6 jwin_center_dialog(assignscript_dlg);
20571 6 }
20572 //}
20573 6 }
20574
20575 std::string global_slotnames[NUMSCRIPTGLOBAL] = {
20576 "Init",
20577 "Active",
20578 "onExit",
20579 "onSaveLoad",
20580 "onLaunch",
20581 "onContGame",
20582 "onF6Menu",
20583 "onSave",
20584 };
20585 std::string player_slotnames[NUMSCRIPTHERO-1] = {
20586 "Init",
20587 "Active",
20588 "onDeath",
20589 "onWin",
20590 };
20591 6 byte reload_scripts(map<string, disassembled_script_data> &scripts)
20592 {
20593 6 byte slotflags = 0;
20594 char temp[100];
20595
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(int32_t i = 0; i < NUMSCRIPTFFC-1; i++)
20596 {
20597
2/2
✓ Branch 0 taken 2992 times.
✓ Branch 1 taken 74 times.
3066 if(ffcmap[i].isEmpty())
20598 2992 sprintf(temp, "Slot %d:", i+1);
20599 else
20600 {
20601 74 sprintf(temp, "Slot %d:", i+1);
20602
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 5 times.
74 if(scripts.find(ffcmap[i].scriptname) != scripts.end())
20603 69 ffcmap[i].format = SCRIPT_FORMAT_DEFAULT;
20604 else // Previously loaded script not found
20605 {
20606 5 ffcmap[i].format = SCRIPT_FORMAT_INVALID;
20607 5 slotflags |= SLOTMSGFLAG_MISSING;
20608 }
20609 }
20610 3066 ffcmap[i].slotname = temp;
20611 3066 ffcmap[i].update();
20612 3066 }
20613
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 6 times.
54 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; i++)
20614 {
20615
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 globalmap[i].slotname=fmt::format("{}:",global_slotnames[i]);
20616
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 11 times.
48 if(!globalmap[i].isEmpty())
20617 {
20618
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 if(scripts.find(globalmap[i].scriptname) != scripts.end() || globalmap[i].scriptname == "~Init")
20619 11 globalmap[i].format = SCRIPT_FORMAT_DEFAULT;
20620 else // Unloaded
20621 {
20622 globalmap[i].format = SCRIPT_FORMAT_INVALID;
20623 slotflags |= SLOTMSGFLAG_MISSING;
20624 }
20625 11 }
20626 48 globalmap[i].update();
20627 48 }
20628
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTITEM-1; i++)
20629 {
20630
2/2
✓ Branch 0 taken 1517 times.
✓ Branch 1 taken 13 times.
1530 if(itemmap[i].isEmpty())
20631 1517 sprintf(temp, "Slot %d:", i+1);
20632 else
20633 {
20634 13 sprintf(temp, "Slot %d:", i+1);
20635
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(scripts.find(itemmap[i].scriptname) != scripts.end())
20636 13 itemmap[i].format = SCRIPT_FORMAT_DEFAULT;
20637 else // Previously loaded script not found
20638 {
20639 itemmap[i].format = SCRIPT_FORMAT_INVALID;
20640 slotflags |= SLOTMSGFLAG_MISSING;
20641 }
20642 }
20643 1530 itemmap[i].slotname = temp;
20644 1530 itemmap[i].update();
20645 1530 }
20646
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTGUYS-1; i++)
20647 {
20648
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(npcmap[i].isEmpty())
20649 1530 sprintf(temp, "Slot %d:", i+1);
20650 else
20651 {
20652 sprintf(temp, "Slot %d:", i+1);
20653 if(scripts.find(npcmap[i].scriptname) != scripts.end())
20654 npcmap[i].format = SCRIPT_FORMAT_DEFAULT;
20655 else // Previously loaded script not found
20656 {
20657 npcmap[i].format = SCRIPT_FORMAT_INVALID;
20658 slotflags |= SLOTMSGFLAG_MISSING;
20659 }
20660 }
20661 1530 npcmap[i].slotname = temp;
20662 1530 npcmap[i].update();
20663 1530 }
20664
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTWEAPONS-1; i++)
20665 {
20666
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(ewpnmap[i].isEmpty())
20667 1530 sprintf(temp, "Slot %d:", i+1);
20668 else
20669 {
20670 sprintf(temp, "Slot %d:", i+1);
20671 if(scripts.find(ewpnmap[i].scriptname) != scripts.end())
20672 ewpnmap[i].format = SCRIPT_FORMAT_DEFAULT;
20673 else // Previously loaded script not found
20674 {
20675 ewpnmap[i].format = SCRIPT_FORMAT_INVALID;
20676 slotflags |= SLOTMSGFLAG_MISSING;
20677 }
20678 }
20679 1530 ewpnmap[i].slotname = temp;
20680 1530 ewpnmap[i].update();
20681 1530 }
20682
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTWEAPONS-1; i++)
20683 {
20684
2/2
✓ Branch 0 taken 1529 times.
✓ Branch 1 taken 1 times.
1530 if(lwpnmap[i].isEmpty())
20685 1529 sprintf(temp, "Slot %d:", i+1);
20686 else
20687 {
20688 1 sprintf(temp, "Slot %d:", i+1);
20689
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(scripts.find(lwpnmap[i].scriptname) != scripts.end())
20690 1 lwpnmap[i].format = SCRIPT_FORMAT_DEFAULT;
20691 else // Previously loaded script not found
20692 {
20693 lwpnmap[i].format = SCRIPT_FORMAT_INVALID;
20694 slotflags |= SLOTMSGFLAG_MISSING;
20695 }
20696 }
20697 1530 lwpnmap[i].slotname = temp;
20698 1530 lwpnmap[i].update();
20699 1530 }
20700
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
30 for(int32_t i = 0; i < NUMSCRIPTHERO-1; i++)
20701 {
20702
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 playermap[i].slotname=fmt::format("{}:",player_slotnames[i]);
20703
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!playermap[i].isEmpty())
20704 {
20705 if(scripts.find(playermap[i].scriptname) != scripts.end())
20706 playermap[i].format = SCRIPT_FORMAT_DEFAULT;
20707 else // Unloaded
20708 {
20709 playermap[i].format = SCRIPT_FORMAT_INVALID;
20710 slotflags |= SLOTMSGFLAG_MISSING;
20711 }
20712 }
20713 24 playermap[i].update();
20714 24 }
20715
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSCREEN-1; i++)
20716 {
20717
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 2 times.
1530 if(screenmap[i].isEmpty())
20718 1528 sprintf(temp, "Slot %d:", i+1);
20719 else
20720 {
20721 2 sprintf(temp, "Slot %d:", i+1);
20722
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(scripts.find(screenmap[i].scriptname) != scripts.end())
20723 2 screenmap[i].format = SCRIPT_FORMAT_DEFAULT;
20724 else // Previously loaded script not found
20725 {
20726 screenmap[i].format = SCRIPT_FORMAT_INVALID;
20727 slotflags |= SLOTMSGFLAG_MISSING;
20728 }
20729 }
20730 1530 screenmap[i].slotname = temp;
20731 1530 screenmap[i].update();
20732 1530 }
20733
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSDMAP-1; i++)
20734 {
20735
2/2
✓ Branch 0 taken 1525 times.
✓ Branch 1 taken 5 times.
1530 if(dmapmap[i].isEmpty())
20736 1525 sprintf(temp, "Slot %d:", i+1);
20737 else
20738 {
20739 5 sprintf(temp, "Slot %d:", i+1);
20740
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(scripts.find(dmapmap[i].scriptname) != scripts.end())
20741 5 dmapmap[i].format = SCRIPT_FORMAT_DEFAULT;
20742 else // Previously loaded script not found
20743 {
20744 dmapmap[i].format = SCRIPT_FORMAT_INVALID;
20745 slotflags |= SLOTMSGFLAG_MISSING;
20746 }
20747 }
20748 1530 dmapmap[i].slotname = temp;
20749 1530 dmapmap[i].update();
20750 1530 }
20751
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE-1; i++)
20752 {
20753
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(itemspritemap[i].isEmpty())
20754 1530 sprintf(temp, "Slot %d:", i+1);
20755 else
20756 {
20757 sprintf(temp, "Slot %d:", i+1);
20758 if(scripts.find(itemspritemap[i].scriptname) != scripts.end())
20759 itemspritemap[i].format = SCRIPT_FORMAT_DEFAULT;
20760 else // Previously loaded script not found
20761 {
20762 itemspritemap[i].format = SCRIPT_FORMAT_INVALID;
20763 slotflags |= SLOTMSGFLAG_MISSING;
20764 }
20765 }
20766 1530 itemspritemap[i].slotname = temp;
20767 1530 itemspritemap[i].update();
20768 1530 }
20769
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA-1; i++)
20770 {
20771
1/2
✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
3066 if(comboscriptmap[i].isEmpty())
20772 3066 sprintf(temp, "Slot %d:", i+1);
20773 else
20774 {
20775 sprintf(temp, "Slot %d:", i+1);
20776 if(scripts.find(comboscriptmap[i].scriptname) != scripts.end())
20777 comboscriptmap[i].format = SCRIPT_FORMAT_DEFAULT;
20778 else // Previously loaded script not found
20779 {
20780 comboscriptmap[i].format = SCRIPT_FORMAT_INVALID;
20781 slotflags |= SLOTMSGFLAG_MISSING;
20782 }
20783 }
20784 3066 comboscriptmap[i].slotname = temp;
20785 3066 comboscriptmap[i].update();
20786 3066 }
20787
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(int32_t i = 0; i < NUMSCRIPTSGENERIC-1; i++)
20788 {
20789
2/2
✓ Branch 0 taken 3051 times.
✓ Branch 1 taken 15 times.
3066 if(genericmap[i].isEmpty())
20790 3051 sprintf(temp, "Slot %d:", i+1);
20791 else
20792 {
20793 15 sprintf(temp, "Slot %d:", i+1);
20794
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if(scripts.find(genericmap[i].scriptname) != scripts.end())
20795 14 genericmap[i].format = SCRIPT_FORMAT_DEFAULT;
20796 else // Previously loaded script not found
20797 {
20798 1 genericmap[i].format = SCRIPT_FORMAT_INVALID;
20799 1 slotflags |= SLOTMSGFLAG_MISSING;
20800 }
20801 }
20802 3066 genericmap[i].slotname = temp;
20803 3066 genericmap[i].update();
20804 3066 }
20805
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSSUBSCREEN-1; i++)
20806 {
20807
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(subscreenmap[i].isEmpty())
20808 1530 sprintf(temp, "Slot %d:", i+1);
20809 else
20810 {
20811 sprintf(temp, "Slot %d:", i+1);
20812 if(scripts.find(subscreenmap[i].scriptname) != scripts.end())
20813 subscreenmap[i].format = SCRIPT_FORMAT_DEFAULT;
20814 else // Previously loaded script not found
20815 {
20816 subscreenmap[i].format = SCRIPT_FORMAT_INVALID;
20817 slotflags |= SLOTMSGFLAG_MISSING;
20818 }
20819 }
20820 1530 subscreenmap[i].slotname = temp;
20821 1530 subscreenmap[i].update();
20822 1530 }
20823 6 return slotflags;
20824 }
20825
20826 void doClearSlots(byte* flags);
20827
20828 extern byte compile_success_sample, compile_error_sample,
20829 compile_finish_sample, compile_audio_volume;
20830 static map<string, disassembled_script_data> *doslot_scripts = nullptr;
20831 21510 bool handle_slot(script_slot_data& slotdata, script_data* scriptdata)
20832 {
20833
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 21395 times.
21510 if(slotdata.hasScriptData())
20834 {
20835 115 auto& data = (*doslot_scripts)[slotdata.scriptname];
20836 115 scriptdata->meta = data.meta;
20837 115 scriptdata->pc = data.pc;
20838 115 scriptdata->end_pc = data.end_pc;
20839 115 scriptdata->zasm_script = zasm_scripts[0];
20840 115 }
20841
1/2
✓ Branch 0 taken 21395 times.
✗ Branch 1 not taken.
21395 else if(scriptdata)
20842 {
20843 21395 scriptdata->zasm_script = nullptr;
20844 21395 scriptdata->meta.zero();
20845 21395 scriptdata->pc = 0;
20846 21395 scriptdata->end_pc = 0;
20847 21395 }
20848 21510 return true;
20849 }
20850 78 bool handle_slot_map(map<int32_t, script_slot_data>& mp, int offs, script_data** scriptdata)
20851 {
20852
2/2
✓ Branch 0 taken 21510 times.
✓ Branch 1 taken 78 times.
21588 for(auto it = mp.begin(); it != mp.end(); it++)
20853 {
20854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21510 times.
21510 if(!handle_slot(it->second, scriptdata[it->first + offs]))
20855 return false;
20856 21510 }
20857 78 return true;
20858 78 }
20859
20860 void smart_slot_named(map<string, disassembled_script_data> &scripts,
20861 vector<string> const& scriptnames, map<int32_t, script_slot_data>& mp,
20862 std::string* slotnames, int slotstart, int slotend)
20863 {
20864 for(int q = slotstart; q < slotend; ++q)
20865 {
20866 auto& lval = mp[q];
20867 if(!lval.isEmpty())
20868 continue; //occupied, leave alone
20869 bool done = false;
20870 if(!done) //Check case-sensitive
20871 for(size_t rind = 0; rind < scriptnames.size(); ++rind)
20872 {
20873 auto const& rval = scriptnames[rind];
20874 if(rval == "<none>") continue;
20875 if(rval == slotnames[q])
20876 { //Perfect match
20877 lval.updateName(rval);
20878 lval.format = scripts[lval.scriptname].format;
20879 done = true;
20880 break;
20881 }
20882 }
20883 if(!done) //Check case-insensitive
20884 for(size_t rind = 0; rind < scriptnames.size(); ++rind)
20885 {
20886 auto const& rval = scriptnames[rind];
20887 if(rval == "<none>") continue;
20888 string lc_rv = rval, lc_slot = slotnames[q];
20889 lowerstr(lc_rv);
20890 lowerstr(lc_slot);
20891 if(lc_rv == lc_slot)
20892 { //Insensitive match
20893 lval.updateName(rval);
20894 lval.format = scripts[lval.scriptname].format;
20895 break;
20896 }
20897 }
20898 }
20899 }
20900 void smart_slot_type(map<string, disassembled_script_data> &scripts,
20901 vector<string> const& scriptnames, map<int32_t, script_slot_data>& mp,
20902 int slotcount)
20903 {
20904 for(size_t rind = 0; rind < scriptnames.size(); ++rind)
20905 {
20906 auto const& rval = scriptnames[rind];
20907 if(rval == "<none>") continue;
20908 script_slot_data* first_open_slot = nullptr;
20909 bool done = false;
20910 for(int q = 0; q < slotcount; ++q)
20911 {
20912 auto& lval = mp[q];
20913 if(lval.isEmpty())
20914 {
20915 if(!first_open_slot)
20916 first_open_slot = &lval;
20917 }
20918 else if(lval.scriptname == rval)
20919 {
20920 done = true;
20921 break;
20922 }
20923 }
20924 if(!done)
20925 {
20926 if(!first_open_slot)
20927 break; //no slots left to assign to!
20928 first_open_slot->updateName(rval);
20929 first_open_slot->format = scripts[first_open_slot->scriptname].format;
20930 }
20931 }
20932 }
20933
20934 6 bool do_slots(vector<shared_ptr<ZScript::Opcode>> const& zasm,
20935 map<string, disassembled_script_data> &scripts, int assign_mode)
20936 {
20937 6 large_dialog(assignscript_dlg);
20938 6 int32_t ret = 3;
20939 6 char slots_msg[SLOTMSG_SIZE] = {0};
20940 6 byte slotflags = reload_scripts(scripts);
20941 6 setup_scriptslot_dlg(slots_msg, slotflags);
20942 6 bool retval = false;
20943
20944 6 popup_zqdialog_start();
20945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 while(!assign_mode)
20946 {
20947 slotflags = reload_scripts(scripts);
20948 ret = do_zqdialog(assignscript_dlg, ret);
20949
20950 switch(ret)
20951 {
20952 case 0:
20953 case 2:
20954 //Cancel
20955 goto exit_do_slots;
20956
20957 case 3: goto auto_do_slots;
20958
20959 case 6:
20960 //<<, FFC
20961 {
20962 int32_t lind = assignscript_dlg[4].d1;
20963 int32_t rind = assignscript_dlg[5].d1;
20964
20965 if(lind < 0 || rind < 0)
20966 break;
20967
20968 if(asffcscripts[rind] == "<none>")
20969 {
20970 ffcmap[lind].scriptname = "";
20971 ffcmap[lind].format = SCRIPT_FORMAT_DEFAULT;
20972 }
20973 else
20974 {
20975 ffcmap[lind].updateName(asffcscripts[rind]);
20976 ffcmap[lind].format = scripts[ffcmap[lind].scriptname].format;
20977 }
20978
20979 break;
20980 }
20981 case 9:
20982 //<<, Global
20983 {
20984 int32_t lind = assignscript_dlg[7].d1;
20985 int32_t rind = assignscript_dlg[8].d1;
20986
20987 if(lind < 0 || rind < 0)
20988 break;
20989
20990 if(lind == 0)
20991 {
20992 jwin_alert("Error","ZScript reserves this slot.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
20993 break;
20994 }
20995
20996 if(asglobalscripts[rind] == "<none>")
20997 {
20998 globalmap[lind].scriptname = "";
20999 globalmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21000 }
21001 else
21002 {
21003 globalmap[lind].updateName(asglobalscripts[rind]);
21004 globalmap[lind].format = scripts[globalmap[lind].scriptname].format;
21005 }
21006
21007 break;
21008 }
21009 case 12:
21010 //<<, ITEM
21011 {
21012 int32_t lind = assignscript_dlg[10].d1;
21013 int32_t rind = assignscript_dlg[11].d1;
21014
21015 if(lind < 0 || rind < 0)
21016 break;
21017
21018 if(asitemscripts[rind] == "<none>")
21019 {
21020 itemmap[lind].scriptname = "";
21021 itemmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21022 }
21023 else
21024 {
21025 itemmap[lind].updateName(asitemscripts[rind]);
21026 itemmap[lind].format = scripts[itemmap[lind].scriptname].format;
21027 }
21028
21029 break;
21030 }
21031 case 20:
21032 //<<, NPC
21033 {
21034 int32_t lind = assignscript_dlg[18].d1;
21035 int32_t rind = assignscript_dlg[19].d1;
21036
21037 if(lind < 0 || rind < 0)
21038 break;
21039
21040 if(asnpcscripts[rind] == "<none>")
21041 {
21042 npcmap[lind].scriptname = "";
21043 npcmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21044 }
21045 else
21046 {
21047 npcmap[lind].updateName(asnpcscripts[rind]);
21048 npcmap[lind].format = scripts[npcmap[lind].scriptname].format;
21049 }
21050
21051 break;
21052 }
21053 case 23:
21054 //<<, LWeapon
21055 {
21056 int32_t lind = assignscript_dlg[21].d1;
21057 int32_t rind = assignscript_dlg[22].d1;
21058
21059 if(lind < 0 || rind < 0)
21060 break;
21061
21062 if(aslweaponscripts[rind] == "<none>")
21063 {
21064 lwpnmap[lind].scriptname = "";
21065 lwpnmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21066 }
21067 else
21068 {
21069 lwpnmap[lind].updateName(aslweaponscripts[rind]);
21070 lwpnmap[lind].format = scripts[lwpnmap[lind].scriptname].format;
21071 }
21072
21073 break;
21074 }
21075 case 26:
21076 //<<, EWeapon
21077 {
21078 int32_t lind = assignscript_dlg[24].d1;
21079 int32_t rind = assignscript_dlg[25].d1;
21080
21081 if(lind < 0 || rind < 0)
21082 break;
21083
21084 if(aseweaponscripts[rind] == "<none>")
21085 {
21086 ewpnmap[lind].scriptname = "";
21087 ewpnmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21088 }
21089 else
21090 {
21091 ewpnmap[lind].updateName(aseweaponscripts[rind]);
21092 ewpnmap[lind].format = scripts[ewpnmap[lind].scriptname].format;
21093 }
21094
21095 break;
21096 }
21097 case 29:
21098 //<<, Hero
21099 {
21100 int32_t lind = assignscript_dlg[27].d1;
21101 int32_t rind = assignscript_dlg[28].d1;
21102
21103 if(lind < 0 || rind < 0)
21104 break;
21105
21106 if(asplayerscripts[rind] == "<none>")
21107 {
21108 playermap[lind].scriptname = "";
21109 playermap[lind].format = SCRIPT_FORMAT_DEFAULT;
21110 }
21111 else
21112 {
21113 playermap[lind].updateName(asplayerscripts[rind]);
21114 playermap[lind].format = scripts[playermap[lind].scriptname].format;
21115 }
21116
21117 break;
21118 }
21119 case 32:
21120 //<<, Screendata
21121 {
21122 int32_t lind = assignscript_dlg[30].d1;
21123 int32_t rind = assignscript_dlg[31].d1;
21124
21125 if(lind < 0 || rind < 0)
21126 break;
21127
21128 if(asscreenscripts[rind] == "<none>")
21129 {
21130 screenmap[lind].scriptname = "";
21131 screenmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21132 }
21133 else
21134 {
21135 screenmap[lind].updateName(asscreenscripts[rind]);
21136 screenmap[lind].format = scripts[screenmap[lind].scriptname].format;
21137 }
21138
21139 break;
21140 }
21141 case 35:
21142 //<<, dmapdata
21143 {
21144 int32_t lind = assignscript_dlg[33].d1;
21145 int32_t rind = assignscript_dlg[34].d1;
21146
21147 if(lind < 0 || rind < 0)
21148 break;
21149
21150 if(asdmapscripts[rind] == "<none>")
21151 {
21152 dmapmap[lind].scriptname = "";
21153 dmapmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21154 }
21155 else
21156 {
21157 dmapmap[lind].updateName(asdmapscripts[rind]);
21158 dmapmap[lind].format = scripts[dmapmap[lind].scriptname].format;
21159 }
21160
21161 break;
21162 }
21163 case 38:
21164 //<<, itemsprite
21165 {
21166 int32_t lind = assignscript_dlg[36].d1;
21167 int32_t rind = assignscript_dlg[37].d1;
21168
21169 if(lind < 0 || rind < 0)
21170 break;
21171
21172 if(asitemspritescripts[rind] == "<none>")
21173 {
21174 itemspritemap[lind].scriptname = "";
21175 itemspritemap[lind].format = SCRIPT_FORMAT_DEFAULT;
21176 }
21177 else
21178 {
21179 itemspritemap[lind].updateName(asitemspritescripts[rind]);
21180 itemspritemap[lind].format = scripts[itemspritemap[lind].scriptname].format;
21181 }
21182
21183 break;
21184 }
21185 case 41:
21186 //<<, comboscript
21187 {
21188 int32_t lind = assignscript_dlg[39].d1;
21189 int32_t rind = assignscript_dlg[40].d1;
21190
21191 if(lind < 0 || rind < 0)
21192 break;
21193
21194 if(ascomboscripts[rind] == "<none>")
21195 {
21196 comboscriptmap[lind].scriptname = "";
21197 comboscriptmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21198 }
21199 else
21200 {
21201 comboscriptmap[lind].updateName(ascomboscripts[rind]);
21202 comboscriptmap[lind].format = scripts[comboscriptmap[lind].scriptname].format;
21203 }
21204
21205 break;
21206 }
21207 case 47:
21208 //<<, generic script
21209 {
21210 int32_t lind = assignscript_dlg[45].d1;
21211 int32_t rind = assignscript_dlg[46].d1;
21212
21213 if(lind < 0 || rind < 0)
21214 break;
21215
21216 if(asgenericscripts[rind] == "<none>")
21217 {
21218 genericmap[lind].scriptname = "";
21219 genericmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21220 }
21221 else
21222 {
21223 genericmap[lind].updateName(asgenericscripts[rind]);
21224 genericmap[lind].format = scripts[genericmap[lind].scriptname].format;
21225 }
21226
21227 break;
21228 }
21229 case 50:
21230 //<<, subscreen script
21231 {
21232 int32_t lind = assignscript_dlg[48].d1;
21233 int32_t rind = assignscript_dlg[49].d1;
21234
21235 if(lind < 0 || rind < 0)
21236 break;
21237
21238 if(assubscreenscripts[rind] == "<none>")
21239 {
21240 subscreenmap[lind].scriptname = "";
21241 subscreenmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21242 }
21243 else
21244 {
21245 subscreenmap[lind].updateName(assubscreenscripts[rind]);
21246 subscreenmap[lind].format = scripts[subscreenmap[lind].scriptname].format;
21247 }
21248
21249 break;
21250 }
21251
21252 case 42:
21253 //Script Info, information
21254 {
21255 disassembled_script_data* target = nullptr;
21256 switch(get_selected_tab((TABPANEL*)assignscript_dlg[1].dp))
21257 {
21258 default:
21259 case 0: //FFC
21260 {
21261 int32_t id = assignscript_dlg[4].d1;
21262 if(id > -1 && ffcmap[id].hasScriptData())
21263 {
21264 target = &(scripts[ffcmap[id].scriptname]);
21265 }
21266 break;
21267 }
21268 case 1: //Global
21269 {
21270 int32_t id = assignscript_dlg[7].d1;
21271 if(id > -1 && globalmap[id].hasScriptData())
21272 {
21273 target = &(scripts[globalmap[id].scriptname]);
21274 }
21275 break;
21276 }
21277 case 2: //Item
21278 {
21279 int32_t id = assignscript_dlg[10].d1;
21280 if(id > -1 && itemmap[id].hasScriptData())
21281 {
21282 target = &(scripts[itemmap[id].scriptname]);
21283 }
21284 break;
21285 }
21286 case 3: //npc
21287 {
21288 int32_t id = assignscript_dlg[19].d1;
21289 if(id > -1 && npcmap[id].hasScriptData())
21290 {
21291 target = &(scripts[npcmap[id].scriptname]);
21292 }
21293 break;
21294 }
21295 case 4: //lweapon
21296 {
21297 int32_t id = assignscript_dlg[21].d1;
21298 if(id > -1 && lwpnmap[id].hasScriptData())
21299 {
21300 target = &(scripts[lwpnmap[id].scriptname]);
21301 }
21302 break;
21303 }
21304 case 5: //eweapon
21305 {
21306 int32_t id = assignscript_dlg[24].d1;
21307 if(id > -1 && ewpnmap[id].hasScriptData())
21308 {
21309 target = &(scripts[ewpnmap[id].scriptname]);
21310 }
21311 break;
21312 }
21313 case 6: //hero
21314 {
21315 int32_t id = assignscript_dlg[27].d1;
21316 if(id > -1 && playermap[id].hasScriptData())
21317 {
21318 target = &(scripts[playermap[id].scriptname]);
21319 }
21320 break;
21321 }
21322 case 7: //dmap
21323 {
21324 int32_t id = assignscript_dlg[33].d1;
21325 if(id > -1 && dmapmap[id].hasScriptData())
21326 {
21327 target = &(scripts[dmapmap[id].scriptname]);
21328 }
21329 break;
21330 }
21331 case 8: //screen
21332 {
21333 int32_t id = assignscript_dlg[30].d1;
21334 if(id > -1 && screenmap[id].hasScriptData())
21335 {
21336 target = &(scripts[screenmap[id].scriptname]);
21337 }
21338 break;
21339 }
21340 case 9: //itemsprite
21341 {
21342 int32_t id = assignscript_dlg[36].d1;
21343 if(id > -1 && itemspritemap[id].hasScriptData())
21344 {
21345 target = &(scripts[itemspritemap[id].scriptname]);
21346 }
21347 break;
21348 }
21349 case 10: //combo
21350 {
21351 int32_t id = assignscript_dlg[39].d1;
21352 if(id > -1 && comboscriptmap[id].hasScriptData())
21353 {
21354 target = &(scripts[comboscriptmap[id].scriptname]);
21355 }
21356 break;
21357 }
21358 case 11: //Generic
21359 {
21360 int32_t id = assignscript_dlg[45].d1;
21361 if(id > -1 && genericmap[id].hasScriptData())
21362 {
21363 target = &(scripts[genericmap[id].scriptname]);
21364 }
21365 break;
21366 }
21367 case 12: //Subscreen
21368 {
21369 int32_t id = assignscript_dlg[48].d1;
21370 if(id > -1 && subscreenmap[id].hasScriptData())
21371 {
21372 target = &(scripts[subscreenmap[id].scriptname]);
21373 }
21374 break;
21375 }
21376 }
21377 if(target)
21378 showScriptInfo(&target->meta);
21379 break;
21380 }
21381
21382 case 43:
21383 //Script Info, information
21384 {
21385 disassembled_script_data* target = NULL;
21386 switch(get_selected_tab((TABPANEL*)assignscript_dlg[1].dp))
21387 {
21388 default:
21389 case 0: //FFC
21390 {
21391 int32_t id = assignscript_dlg[5].d1;
21392 if(id < 0 || asffcscripts[id] == "<none>" || asffcscripts[id].at(0) == '-') break;
21393 target = &(scripts[asffcscripts[id]]);
21394 break;
21395 }
21396 case 1: //Global
21397 {
21398 int32_t id = assignscript_dlg[8].d1;
21399 if(id < 0 || asglobalscripts[id] == "<none>" || asglobalscripts[id].at(0) == '-') break;
21400 target = &(scripts[asglobalscripts[id]]);
21401 break;
21402 }
21403 case 2: //Item
21404 {
21405 int32_t id = assignscript_dlg[11].d1;
21406 if(id < 0 || asitemscripts[id] == "<none>" || asitemscripts[id].at(0) == '-') break;
21407 target = &(scripts[asitemscripts[id]]);
21408 break;
21409 }
21410 case 3: //npc
21411 {
21412 int32_t id = assignscript_dlg[20].d1;
21413 if(id < 0 || asnpcscripts[id] == "<none>" || asnpcscripts[id].at(0) == '-') break;
21414 target = &(scripts[asnpcscripts[id]]);
21415 break;
21416 }
21417 case 4: //lweapon
21418 {
21419 int32_t id = assignscript_dlg[22].d1;
21420 if(id < 0 || aslweaponscripts[id] == "<none>" || aslweaponscripts[id].at(0) == '-') break;
21421 target = &(scripts[aslweaponscripts[id]]);
21422 break;
21423 }
21424 case 5: //eweapon
21425 {
21426 int32_t id = assignscript_dlg[25].d1;
21427 if(id < 0 || aseweaponscripts[id] == "<none>" || aseweaponscripts[id].at(0) == '-') break;
21428 target = &(scripts[aseweaponscripts[id]]);
21429 break;
21430 }
21431 case 6: //hero
21432 {
21433 int32_t id = assignscript_dlg[28].d1;
21434 if(id < 0 || asplayerscripts[id] == "<none>" || asplayerscripts[id].at(0) == '-') break;
21435 target = &(scripts[asplayerscripts[id]]);
21436 break;
21437 }
21438 case 7: //dmap
21439 {
21440 int32_t id = assignscript_dlg[34].d1;
21441 if(id < 0 || asdmapscripts[id] == "<none>" || asdmapscripts[id].at(0) == '-') break;
21442 target = &(scripts[asdmapscripts[id]]);
21443 break;
21444 }
21445 case 8: //screen
21446 {
21447 int32_t id = assignscript_dlg[31].d1;
21448 if(id < 0 || asscreenscripts[id] == "<none>" || asscreenscripts[id].at(0) == '-') break;
21449 target = &(scripts[asscreenscripts[id]]);
21450 break;
21451 }
21452 case 9: //itemsprite
21453 {
21454 int32_t id = assignscript_dlg[37].d1;
21455 if(id < 0 || asitemspritescripts[id] == "<none>" || asitemspritescripts[id].at(0) == '-') break;
21456 target = &(scripts[asitemspritescripts[id]]);
21457 break;
21458 }
21459 case 10: //combo
21460 {
21461 int32_t id = assignscript_dlg[40].d1;
21462 if(id < 0 || ascomboscripts[id] == "<none>" || ascomboscripts[id].at(0) == '-') break;
21463 target = &(scripts[ascomboscripts[id]]);
21464 break;
21465 }
21466 case 11: //generic
21467 {
21468 int32_t id = assignscript_dlg[46].d1;
21469 if(id < 0 || asgenericscripts[id] == "<none>" || asgenericscripts[id].at(0) == '-') break;
21470 target = &(scripts[asgenericscripts[id]]);
21471 break;
21472 }
21473 case 12: //subscreen
21474 {
21475 int32_t id = assignscript_dlg[49].d1;
21476 if(id < 0 || assubscreenscripts[id] == "<none>" || assubscreenscripts[id].at(0) == '-') break;
21477 target = &(scripts[assubscreenscripts[id]]);
21478 break;
21479 }
21480 }
21481 if(target)
21482 showScriptInfo(&target->meta);
21483 break;
21484 }
21485
21486 case 44:
21487 //Clear, clear slots of current type- after a confirmation.
21488 {
21489 doClearSlots(&slotflags);
21490 break;
21491 }
21492 }
21493 }
21494
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(assign_mode == 2) //Smart Assign
21495 {
21496 //For global/hero scripts, match slot names if unoccupied
21497 smart_slot_named(scripts, asglobalscripts, globalmap, global_slotnames, 1, NUMSCRIPTGLOBAL);
21498 smart_slot_named(scripts, asplayerscripts, playermap, player_slotnames, 0, NUMSCRIPTHERO-1);
21499 //For other scripts, assign all un-assigned scripts
21500 smart_slot_type(scripts, asffcscripts, ffcmap, NUMSCRIPTFFC-1);
21501 smart_slot_type(scripts, asitemscripts, itemmap, NUMSCRIPTITEM-1);
21502 smart_slot_type(scripts, asnpcscripts, npcmap, NUMSCRIPTGUYS-1);
21503 smart_slot_type(scripts, aslweaponscripts, lwpnmap, NUMSCRIPTWEAPONS-1);
21504 smart_slot_type(scripts, aseweaponscripts, ewpnmap, NUMSCRIPTWEAPONS-1);
21505 smart_slot_type(scripts, asscreenscripts, screenmap, NUMSCRIPTSCREEN-1);
21506 smart_slot_type(scripts, asdmapscripts, dmapmap, NUMSCRIPTSDMAP-1);
21507 smart_slot_type(scripts, asitemspritescripts, itemspritemap, NUMSCRIPTSITEMSPRITE-1);
21508 smart_slot_type(scripts, ascomboscripts, comboscriptmap, NUMSCRIPTSCOMBODATA-1);
21509 smart_slot_type(scripts, asgenericscripts, genericmap, NUMSCRIPTSGENERIC-1);
21510 smart_slot_type(scripts, assubscreenscripts, subscreenmap, NUMSCRIPTSSUBSCREEN-1);
21511 }
21512 auto_do_slots:
21513 6 doslots_log_output = (assignscript_dlg[13].flags == D_SELECTED);
21514 6 doslots_comment_output = (assignscript_dlg[51].flags == D_SELECTED);
21515 6 doslot_scripts = &scripts;
21516 //OK
21517 {
21518
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(doslots_log_output)
21519 {
21520 string outstr;
21521 write_script(zasm, outstr, doslots_comment_output, doslot_scripts);
21522 safe_al_trace(outstr);
21523 }
21524 6 auto start_assign_time = std::chrono::steady_clock::now();
21525 6 string zasm_str;
21526
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 write_script(zasm, zasm_str, false, nullptr);
21527
21528 6 std::vector<ffscript> zasm;
21529
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(parse_script_string(zasm, zasm_str, false))
21530 goto exit_do_slots;
21531
21532 6 zasm_scripts.clear();
21533
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 zasm_scripts.emplace_back(std::make_shared<zasm_script>(std::move(zasm)));
21534
21535
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(ffcmap, 1, ffscripts))
21536 goto exit_do_slots;
21537
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(globalmap, 0, globalscripts))
21538 goto exit_do_slots;
21539
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(itemmap, 1, itemscripts))
21540 goto exit_do_slots;
21541
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(npcmap, 1, guyscripts))
21542 goto exit_do_slots;
21543
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(lwpnmap, 1, lwpnscripts))
21544 goto exit_do_slots;
21545
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(ewpnmap, 1, ewpnscripts))
21546 goto exit_do_slots;
21547
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(playermap, 1, playerscripts))
21548 goto exit_do_slots;
21549
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(dmapmap, 1, dmapscripts))
21550 goto exit_do_slots;
21551
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(screenmap, 1, screenscripts))
21552 goto exit_do_slots;
21553
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(itemspritemap, 1, itemspritescripts))
21554 goto exit_do_slots;
21555
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(comboscriptmap, 1, comboscripts))
21556 goto exit_do_slots;
21557
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(genericmap, 1, genericscripts))
21558 goto exit_do_slots;
21559
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(subscreenmap, 1, subscreenscripts))
21560 goto exit_do_slots;
21561
21562 6 auto end_assign_time = std::chrono::steady_clock::now();
21563
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 int compile_time_ms = std::chrono::duration_cast<std::chrono::milliseconds>(end_assign_time - start_assign_time).count();
21564
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 al_trace("Assign Slots took %d ms\n", compile_time_ms);
21565 6 char buf[256] = {0};
21566 12 sprintf(buf, "ZScripts successfully loaded into script slots"
21567 6 "\nAssign Slots took %d ms", compile_time_ms);
21568
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 compile_finish_sample = vbound(zc_get_config("Compiler","compile_finish_sample",20),0,255);
21569
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 compile_audio_volume = vbound(zc_get_config("Compiler","compile_audio_volume",200),0,255);
21570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( compile_finish_sample > 0 )
21571 {
21572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(sfxdat)
21573 sfx_voice[compile_finish_sample]=allocate_voice((SAMPLE*)sfxdata[compile_finish_sample].dat);
21574
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else sfx_voice[compile_finish_sample]=allocate_voice(&customsfxdata[compile_finish_sample]);
21575
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 voice_set_volume(sfx_voice[compile_finish_sample], compile_audio_volume);
21576
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 voice_start(sfx_voice[compile_finish_sample]);
21577 6 }
21578
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!assign_mode)
21579 InfoDialog("Slots Assigned",buf).show();
21580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( compile_finish_sample > 0 )
21581 {
21582
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(sfx_voice[compile_finish_sample]!=-1)
21583 {
21584
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 deallocate_voice(sfx_voice[compile_finish_sample]);
21585 6 sfx_voice[compile_finish_sample]=-1;
21586 6 }
21587 6 }
21588
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 build_biffs_list();
21589
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 build_biitems_list();
21590 6 retval = true;
21591 6 goto exit_do_slots;
21592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 }
21593 exit_do_slots:
21594 6 doslot_scripts = nullptr;
21595 6 popup_zqdialog_end();
21596 6 return retval;
21597 }
21598
21599 static char slottype_str_buf[32];
21600
21601 const char *slottype_list(int32_t index, int32_t *list_size)
21602 {
21603 if(index >= 0)
21604 {
21605 bound(index,0,num_types-1);
21606
21607 switch(index)
21608 {
21609 case type_ffc:
21610 strcpy(slottype_str_buf, "FFC");
21611 break;
21612 case type_global:
21613 strcpy(slottype_str_buf, "Global");
21614 break;
21615 case type_itemdata:
21616 strcpy(slottype_str_buf, "Item");
21617 break;
21618 case type_npc:
21619 strcpy(slottype_str_buf, "NPC");
21620 break;
21621 case type_lweapon:
21622 strcpy(slottype_str_buf, "LWeapon");
21623 break;
21624 case type_eweapon:
21625 strcpy(slottype_str_buf, "EWeapon");
21626 break;
21627 case type_hero:
21628 strcpy(slottype_str_buf, "Hero");
21629 break;
21630 case type_dmap:
21631 strcpy(slottype_str_buf, "DMap");
21632 break;
21633 case type_screen:
21634 strcpy(slottype_str_buf, "Screen");
21635 break;
21636 case type_itemsprite:
21637 strcpy(slottype_str_buf, "ItemSprite");
21638 break;
21639 case type_combo:
21640 strcpy(slottype_str_buf, "Combo");
21641 break;
21642 case type_generic:
21643 strcpy(slottype_str_buf, "Generic");
21644 break;
21645 case type_subscreen:
21646 strcpy(slottype_str_buf, "Subscreen");
21647 break;
21648 }
21649
21650 return slottype_str_buf;
21651 }
21652 *list_size = 11;
21653 return NULL;
21654 }
21655 12 static ListData slottype_sel_list(slottype_list, &font);
21656
21657 static DIALOG clearslots_dlg[] =
21658 {
21659 12 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Clear Slots", NULL, NULL },
21660 12 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Confirm", NULL, NULL },
21661 12 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
21662 12 { jwin_droplist_proc, 50, 28+16, 70, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &slottype_sel_list, NULL, NULL },
21663 12 { jwin_radio_proc, 40, 34+00, 81, 9, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "Clear Script Type:", NULL, NULL },
21664 12 { jwin_radio_proc, 40, 34+32, 81, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear Missing (--) Slots", NULL, NULL },
21665 12 { jwin_radio_proc, 40, 34+80, 81, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear All", NULL, NULL },
21666 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
21667 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
21668 };
21669
21670 void doClearSlots(byte* flags)
21671 {
21672 //{ Setup
21673 clearslots_dlg[0].dp2=get_zc_font(font_lfont);
21674 clearslots_dlg[3].d1 = get_selected_tab((TABPANEL*)assignscript_dlg[1].dp); //Default to current tab's type
21675 clearslots_dlg[4].flags |= D_SELECTED;
21676 clearslots_dlg[5].flags &= ~D_SELECTED;
21677 clearslots_dlg[6].flags &= ~D_SELECTED;
21678 if(((*flags) & SLOTMSGFLAG_MISSING) == 0)
21679 clearslots_dlg[5].flags |= D_DISABLED;
21680 else
21681 clearslots_dlg[5].flags &= ~D_DISABLED;
21682 //}
21683
21684 large_dialog(clearslots_dlg);
21685
21686 if(do_zqdialog(clearslots_dlg,2)==1)
21687 {
21688 int32_t q = 3;
21689 while((clearslots_dlg[++q].flags & D_SELECTED) == 0);
21690 switch(q)
21691 {
21692 case 4: //Clear type
21693 {
21694 clearAllSlots(clearslots_dlg[3].d1);
21695 break;
21696 }
21697 case 5: //Clear Missing
21698 {
21699 for(int32_t q = 0; q <= 10; ++q)
21700 clearAllSlots(q,SLOTMSGFLAG_MISSING);
21701 break;
21702 }
21703 case 6: //Clear ALL
21704 {
21705 for(int32_t q = 0; q <= 10; ++q)
21706 clearAllSlots(q);
21707 break;
21708 }
21709 }
21710 }
21711 }
21712
21713 static DIALOG exportzasm_dlg[] =
21714 {
21715 12 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Export ZASM", NULL, NULL },
21716 12 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Confirm", NULL, NULL },
21717 12 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
21718 12 { jwin_droplist_proc, 50, 28+16, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &slottype_sel_list, NULL, NULL },
21719 12 { jwin_droplist_proc, 50, 28+48, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
21720 12 { jwin_text_proc, 50, 28+8, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Type:", NULL, NULL },
21721 12 { jwin_text_proc, 50, 28+40, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Slot:", NULL, NULL },
21722 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
21723 };
21724
21725 static DIALOG importzasm_dlg[] =
21726 {
21727 12 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Import ZASM", NULL, NULL },
21728 12 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Confirm", NULL, NULL },
21729 12 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
21730 12 { jwin_droplist_proc, 50, 28+16, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &slottype_sel_list, NULL, NULL },
21731 12 { jwin_droplist_proc, 50, 28+48, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
21732 // 5
21733 12 { jwin_text_proc, 50, 28+8, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Type:", NULL, NULL },
21734 12 { jwin_text_proc, 50, 28+40, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Slot:", NULL, NULL },
21735 12 { jwin_text_proc, 50, 28+72, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Name:", NULL, NULL },
21736 12 { jwin_edit_proc, 50, 28+80, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 19, 0, NULL, NULL, NULL },
21737
21738 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
21739 };
21740 extern ListData itemscript_list;
21741 extern ListData itemspritescript_list;
21742 extern ListData lweaponscript_list;
21743 extern ListData npcscript_list;
21744 extern ListData eweaponscript_list;
21745 extern ListData comboscript_list;
21746
21747 8 void center_zscript_dialogs()
21748 {
21749 8 jwin_center_dialog(exportzasm_dlg);
21750 8 jwin_center_dialog(importzasm_dlg);
21751 8 jwin_center_dialog(clearslots_dlg);
21752 8 }
21753
21754 // array of voices, one for each sfx sample in the data file
21755 // 0+ = voice #
21756 // -1 = voice not allocated
21757 int32_t sfx_voice[WAV_COUNT];
21758
21759 void Z_init_sound()
21760 {
21761 for(int32_t i=0; i<WAV_COUNT; i++)
21762 sfx_voice[i]=-1;
21763
21764 // master_volume(digi_volume,midi_volume);
21765 }
21766
21767 // returns number of voices currently allocated
21768 int32_t sfx_count()
21769 {
21770 int32_t c=0;
21771
21772 for(int32_t i=0; i<WAV_COUNT; i++)
21773 if(sfx_voice[i]!=-1)
21774 ++c;
21775
21776 return c;
21777 }
21778
21779 // clean up finished samples
21780 void sfx_cleanup()
21781 {
21782 for(int32_t i=0; i<WAV_COUNT; i++)
21783 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
21784 {
21785 deallocate_voice(sfx_voice[i]);
21786 sfx_voice[i]=-1;
21787 }
21788 }
21789
21790 // allocates a voice for the sample "wav_index" (index into zelda.dat)
21791 // if a voice is already allocated (and/or playing), then it just returns true
21792 // Returns true: voice is allocated
21793 // false: unsuccessful
21794 SAMPLE templist[WAV_COUNT];
21795
21796 bool sfx_init(int32_t index)
21797 {
21798 // check index
21799 if(index<1 || index>=WAV_COUNT)
21800 return false;
21801
21802 if(sfx_voice[index]==-1)
21803 {
21804 sfx_voice[index]=allocate_voice(&templist[index]);
21805 }
21806
21807 return sfx_voice[index] != -1;
21808 }
21809
21810 // plays an sfx sample
21811 void sfx(int32_t index,int32_t pan,bool loop,bool restart,int32_t vol,int32_t freq)
21812 {
21813 if(!sfx_init(index))
21814 return;
21815
21816 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
21817 voice_set_pan(sfx_voice[index],pan);
21818
21819 int32_t pos = voice_get_position(sfx_voice[index]);
21820
21821 if(restart) voice_set_position(sfx_voice[index],0);
21822
21823 if(pos<=0)
21824 voice_start(sfx_voice[index]);
21825 }
21826
21827 // start it (in loop mode) if it's not already playing,
21828 // otherwise just leave it in its current position
21829 void cont_sfx(int32_t index)
21830 {
21831 if(!sfx_init(index))
21832 return;
21833
21834 if(voice_get_position(sfx_voice[index])<=0)
21835 {
21836 voice_set_position(sfx_voice[index],0);
21837 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
21838 voice_start(sfx_voice[index]);
21839 }
21840 }
21841
21842 // adjust parameters while playing
21843 void adjust_sfx(int32_t index,int32_t pan,bool loop)
21844 {
21845 if(index<0 || index>=WAV_COUNT || sfx_voice[index]==-1)
21846 return;
21847
21848 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
21849 voice_set_pan(sfx_voice[index],pan);
21850 }
21851
21852 // pauses a voice
21853 void pause_sfx(int32_t index)
21854 {
21855 if(index>=0 && index<WAV_COUNT && sfx_voice[index]!=-1)
21856 voice_stop(sfx_voice[index]);
21857 }
21858
21859 // resumes a voice
21860 void resume_sfx(int32_t index)
21861 {
21862 if(index>=0 && index<WAV_COUNT && sfx_voice[index]!=-1)
21863 voice_start(sfx_voice[index]);
21864 }
21865
21866 // pauses all active voices
21867 void pause_all_sfx()
21868 {
21869 for(int32_t i=0; i<WAV_COUNT; i++)
21870 if(sfx_voice[i]!=-1)
21871 voice_stop(sfx_voice[i]);
21872 }
21873
21874 // resumes all paused voices
21875 void resume_all_sfx()
21876 {
21877 for(int32_t i=0; i<WAV_COUNT; i++)
21878 if(sfx_voice[i]!=-1)
21879 voice_start(sfx_voice[i]);
21880 }
21881
21882 // stops an sfx and deallocates the voice
21883 void stop_sfx(int32_t index)
21884 {
21885 if(index<0 || index>=WAV_COUNT)
21886 return;
21887
21888 if(sfx_voice[index]!=-1)
21889 {
21890 deallocate_voice(sfx_voice[index]);
21891 sfx_voice[index]=-1;
21892 }
21893 }
21894
21895 void kill_sfx()
21896 {
21897 for(int32_t i=0; i<WAV_COUNT; i++)
21898 if(sfx_voice[i]!=-1)
21899 {
21900 deallocate_voice(sfx_voice[i]);
21901 sfx_voice[i]=-1;
21902 }
21903 }
21904
21905 int32_t pan(int32_t x)
21906 {
21907 return 128;
21908 /*switch(pan_style)
21909 {
21910 case 0: return 128;
21911 case 1: return vbound((x>>1)+68,0,255);
21912 case 2: return vbound(((x*3)>>2)+36,0,255);
21913 }
21914 return vbound(x,0,255);*/
21915 }
21916
21917
21918 void change_sfx(SAMPLE *sfx1, SAMPLE *sfx2)
21919 {
21920 sfx1->bits = sfx2->bits;
21921 sfx1->stereo = sfx2->stereo;
21922 sfx1->freq = sfx2->freq;
21923 sfx1->priority = sfx2->priority;
21924 sfx1->len = sfx2->len;
21925 sfx1->loop_start = sfx2->loop_start;
21926 sfx1->loop_end = sfx2->loop_end;
21927 sfx1->param = sfx2->param;
21928
21929 if(sfx1->data != NULL)
21930 {
21931 free(sfx1->data);
21932 }
21933
21934 if(sfx2->data == NULL)
21935 sfx1->data = NULL;
21936 else
21937 {
21938 // When quests are saved and loaded, data is written in words.
21939 // If the last byte is dropped, it'll cause the sound to end with
21940 // a click. It could simply be extended and padded with 0, but
21941 // that causes compatibility issues... So we'll cut off
21942 // the last byte and decrease the length.
21943
21944 int32_t len = (sfx1->bits==8?1:2)*(sfx1->stereo == 0 ? 1 : 2)*sfx1->len;
21945
21946 while(len%sizeof(word))
21947 {
21948 // sizeof(word) should be 2, so this doesn't really need
21949 // to be a loop, but what the heck.
21950 sfx1->len--;
21951 len = (sfx1->bits==8?1:2)*(sfx1->stereo == 0 ? 1 : 2)*sfx1->len;
21952 }
21953
21954 sfx1->data = malloc(len);
21955 memcpy(sfx1->data, sfx2->data, len);
21956 }
21957 }
21958
21959 bool confirmBox(const char *m1, const char *m2, const char *m3)
21960 {
21961 if(!m3)
21962 {
21963 if(!m2) m2 = "Are you sure?";
21964 else m3 = "Are you sure?";
21965 }
21966 return jwin_alert("Confirmation", m1, m2, m3, "Yes", "No", 'y', 'n', get_zc_font(font_lfont)) == 1;
21967 }
21968
21969 int32_t onSelectSFX()
21970 {
21971 SFXListerDialog(0).show();
21972 refresh(rMAP+rCOMBOS);
21973 return D_O_K;
21974 }
21975
21976 bool saveWAV(int32_t slot, const char *filename)
21977 {
21978 if (slot < 1 || slot >= 511 )
21979 return false;
21980
21981 if (customsfxdata[slot].data == NULL)
21982 return false;
21983
21984 std::ofstream ofs(filename, std::ios::binary);
21985 if (!ofs)
21986 return false;
21987 ofs.write("RIFF",4);
21988 uint32_t samplerate = customsfxdata[slot].freq;
21989 uint16_t channels = customsfxdata[slot].stereo ? 2 : 1;
21990 uint32_t datalen = customsfxdata[slot].len*channels*customsfxdata[slot].bits / 8;
21991 uint32_t size = 36 + datalen;
21992 ofs.write((char *)&size, 4);
21993 ofs.write("WAVE", 4);
21994 ofs.write("fmt ", 4);
21995 uint32_t fmtlen = 16;
21996 ofs.write((char *)&fmtlen, 4);
21997 uint16_t type = 1;
21998 ofs.write((char *)&type, 2);
21999 ofs.write((char *)&channels, 2);
22000 ofs.write((char *)&samplerate, 4);
22001 uint32_t bytespersec = samplerate*channels*customsfxdata[slot].bits / 8;
22002 ofs.write((char *)&bytespersec, 4);
22003 uint16_t blockalign = channels*customsfxdata[slot].bits / 8;
22004 ofs.write((char *)&blockalign, 2);
22005 uint16_t bitspersample = customsfxdata[slot].bits;
22006 ofs.write((char *)&bitspersample, 2);
22007 ofs.write("data", 4);
22008 ofs.write((char *)&datalen, 4);
22009 if (bitspersample == 8)
22010 {
22011 for (int32_t i = 0; i < (int32_t)customsfxdata[slot].len*channels; i++)
22012 {
22013 char data = ((char *)customsfxdata[slot].data)[i];
22014 data ^= 0x80;
22015 ofs.write(&data, 1);
22016 }
22017 }
22018 else if (bitspersample == 16)
22019 {
22020 for (int32_t i = 0; i < (int32_t)customsfxdata[slot].len*channels; i++)
22021 {
22022 uint16_t data = ((uint16_t *)customsfxdata[slot].data)[i];
22023 data ^= 0x8000;
22024 ofs.write((char *)&data, 2);
22025 }
22026 }
22027 else
22028 return false;
22029 return !!ofs;
22030 }
22031
22032 int32_t onEditSFX(int32_t index)
22033 {
22034 call_sfxdata_dialog(index);
22035 return D_O_K;
22036 }
22037
22038 int32_t onMapStyles()
22039 {
22040 call_mapstyles_dialog();
22041 return D_O_K;
22042 }
22043
22044 int32_t d_misccolors_old_proc(int32_t msg,DIALOG *d,int32_t c)
22045 {
22046 //these are here to bypass compiler warnings about unused arguments
22047 c=c;
22048
22049 if(msg==MSG_DRAW)
22050 {
22051 textout_ex(screen,font,"0123456789ABCDEF",d->x+8,d->y,d->fg,d->bg);
22052 textout_ex(screen,font,"0",d->x,d->y+8,d->fg,d->bg);
22053 textout_ex(screen,font,"1",d->x,d->y+16,d->fg,d->bg);
22054 textout_ex(screen,font,"5",d->x,d->y+24,d->fg,d->bg);
22055
22056 for(int32_t i=0; i<32; i++)
22057 {
22058 int32_t px2 = d->x+((i&15)<<3)+8;
22059 int32_t py2 = d->y+((i>>4)<<3)+8;
22060 rectfill(screen,px2,py2,px2+7,py2+7,i);
22061 }
22062
22063 for(int32_t i=0; i<16; i++)
22064 {
22065 int32_t px2 = d->x+(i<<3)+8;
22066 rectfill(screen,px2,d->y+24,px2+7,d->y+31,i+80);
22067 }
22068 }
22069
22070 return D_O_K;
22071 }
22072
22073 int32_t hexclicked=-1;
22074
22075 int32_t d_misccolors_hexedit_proc(int32_t msg,DIALOG *d,int32_t c)
22076 {
22077 switch(msg)
22078 {
22079 case MSG_GOTFOCUS:
22080 hexclicked=((int32_t)(size_t)(d->dp3))+20;
22081 break;
22082
22083 case MSG_LOSTFOCUS:
22084 hexclicked=-1;
22085 break;
22086 }
22087
22088 return d_hexedit_proc(msg,d,c);
22089 }
22090
22091
22092 int32_t d_misccolors_proc(int32_t msg,DIALOG *d,int32_t c);
22093
22094 static int32_t misccolor1_list[] =
22095 {
22096 // dialog control number
22097 4, 5, 6, 7, 8, 20, 21, 22, 23, 24, 36, 37, 38, 39, 40, -1
22098 };
22099
22100 static int32_t misccolor2_list[] =
22101 {
22102 // dialog control number
22103 9, 10, 11, 12, 13, 25, 26, 27, 28, 29, 41, 42, 43, 44, 45, -1
22104 };
22105
22106 static int32_t misccolor3_list[] =
22107 {
22108 // dialog control number
22109 14, 15, 16, 17, 18, 30, 31, 32, 33, 34, 46, 47, 48, 49, 50, -1
22110 };
22111
22112 static int32_t misccolor4_list[] =
22113 {
22114 19, 35, 51, 54, 55, 56, -1
22115 };
22116
22117 static TABPANEL misccolor_tabs[] =
22118 {
22119 // (text)
22120 { (char *)"1", D_SELECTED, misccolor1_list, 0, NULL },
22121 { (char *)"2", 0, misccolor2_list, 0, NULL },
22122 { (char *)"3", 0, misccolor3_list, 0, NULL },
22123 { (char *)"4", 0, misccolor4_list, 0, NULL },
22124 { NULL, 0, NULL, 0, NULL }
22125 };
22126
22127 int32_t d_misccolors_tab_proc(int32_t msg,DIALOG *d,int32_t c);
22128
22129 static DIALOG misccolors_dlg[] =
22130 {
22131 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
22132 12 { jwin_win_proc, 2, 21, 316, 197-23, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Misc Colors", NULL, NULL },
22133 // { jwin_frame_proc, 98-84+1+2, 52+8-6+4, 132, 100, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
22134 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
22135 12 { d_misccolors_proc, 92-84+1+2, 44+8-6+4, 128+8, 96+8, vc(9), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
22136 //3
22137 12 { d_misccolors_tab_proc, 150+14-2+10-15, 60-14, 150-10+15, 144-20-10, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, (void *) misccolor_tabs, NULL, (void *)misccolors_dlg },
22138 //4
22139 12 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Text:", NULL, NULL },
22140 12 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Caption:", NULL, NULL },
22141 12 { jwin_text_proc, 215-25-12-15, 112-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Overworld Minmap:", NULL, NULL },
22142 12 { jwin_text_proc, 215-25-12-15, 130-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimap Background:", NULL, NULL },
22143 12 { jwin_text_proc, 215-25-12-15, 148-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimap Foreground 1:", NULL, NULL },
22144 12 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimap Foreground 2:", NULL, NULL },
22145 12 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "BS Minimap Dark:", NULL, NULL },
22146 12 { jwin_text_proc, 215-25-12-15, 112-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "BS Minimap Goal:", NULL, NULL },
22147 12 { jwin_text_proc, 215-25-12-15, 130-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Compass Mark (Light):", NULL, NULL },
22148 12 { jwin_text_proc, 215-25-12-15, 148-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Compass Mark (Dark):", NULL, NULL },
22149 12 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Subscreen Background:", NULL, NULL },
22150 12 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Subscreen Shadow:", NULL, NULL },
22151 12 { jwin_text_proc, 215-25-12-15, 112-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Triforce Frame:", NULL, NULL },
22152 12 { jwin_text_proc, 215-25-12-15, 130-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Big Map Background:", NULL, NULL },
22153 12 { jwin_text_proc, 215-25-12-15, 148-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Big Map Foreground:", NULL, NULL },
22154 12 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Hero's Position:", NULL, NULL },
22155
22156 //20
22157 12 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)0, },
22158 12 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)1, },
22159 12 { d_misccolors_hexedit_proc, 294-25+14+2, 112-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)2, },
22160 12 { d_misccolors_hexedit_proc, 294-25+14+2, 130-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)3, },
22161 12 { d_misccolors_hexedit_proc, 294-25+14+2, 148-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)4, },
22162 12 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)5, },
22163 12 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)6, },
22164 12 { d_misccolors_hexedit_proc, 294-25+14+2, 112-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)7, },
22165 12 { d_misccolors_hexedit_proc, 294-25+14+2, 130-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)8, },
22166 12 { d_misccolors_hexedit_proc, 294-25+14+2, 148-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)9, },
22167 12 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)10, },
22168 12 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)11, },
22169 12 { d_misccolors_hexedit_proc, 294-25+14+2, 112-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)12, },
22170 12 { d_misccolors_hexedit_proc, 294-25+14+2, 130-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)13, },
22171 12 { d_misccolors_hexedit_proc, 294-25+14+2, 148-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)14, },
22172 12 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)15, },
22173
22174 //36
22175 12 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22176 12 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22177 12 { jwin_text_proc, 283-25+14+2, 112-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22178 12 { jwin_text_proc, 283-25+14+2, 130-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22179 12 { jwin_text_proc, 283-25+14+2, 148-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22180 12 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22181 12 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22182 12 { jwin_text_proc, 283-25+14+2, 112-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22183 12 { jwin_text_proc, 283-25+14+2, 130-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22184 12 { jwin_text_proc, 283-25+14+2, 148-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22185 12 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22186 12 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22187 12 { jwin_text_proc, 283-25+14+2, 112-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22188 12 { jwin_text_proc, 283-25+14+2, 130-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22189 12 { jwin_text_proc, 283-25+14+2, 148-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22190 12 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22191
22192 //52
22193 12 { jwin_button_proc, 90, 190-20, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
22194 12 { jwin_button_proc, 170, 190-20, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
22195 12 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Message Text:", NULL, NULL },
22196 12 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)35, },
22197 12 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22198 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
22199 };
22200
22201 int32_t d_misccolors_tab_proc(int32_t msg,DIALOG *d,int32_t c)
22202 {
22203
22204 switch(msg)
22205 {
22206 case MSG_WANTFOCUS:
22207 return D_WANTFOCUS;
22208 break;
22209 }
22210
22211 return jwin_tab_proc(msg,d,c);
22212 }
22213
22214
22215 int32_t d_misccolors_proc(int32_t msg,DIALOG *d,int32_t c)
22216 {
22217 //these are here to bypass compiler warnings about unused arguments
22218 c=c;
22219 int32_t mul=12;
22220
22221 switch(msg)
22222 {
22223 case MSG_CLICK:
22224 if(hexclicked!=-1)
22225 {
22226 int32_t color_col=vbound(((gui_mouse_x()-d->x-8)/mul),0,15);
22227 int32_t color_row=vbound(((gui_mouse_y()-d->y-10)/mul),0,11);
22228 sprintf((char*)misccolors_dlg[hexclicked].dp,"%X%X",color_row,color_col);
22229 object_message(misccolors_dlg+hexclicked,MSG_DRAW,0);
22230 }
22231
22232 break;
22233
22234 case MSG_DRAW:
22235 for(int32_t i=0; i<10; i++)
22236 {
22237 textprintf_centre_ex(screen,font,d->x+8+4+(i*mul),d->y,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%d", i);
22238 }
22239
22240 for(int32_t i=0; i<6; i++)
22241 {
22242 textprintf_centre_ex(screen,font,d->x+8+4+((10+i)*mul),d->y,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%c", i+'A');
22243 }
22244
22245 for(int32_t i=0; i<10; i++)
22246 {
22247 textprintf_right_ex(screen,font,d->x+6,d->y+(i*mul)+10,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%d", i);
22248 }
22249
22250 for(int32_t i=0; i<2; i++)
22251 {
22252 textprintf_right_ex(screen,font,d->x+6,d->y+((i+10)*mul)+10,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%c", i+'A');
22253 }
22254
22255 jwin_draw_frame(screen,d->x+6,d->y+8,int32_t(132*1.5)-2,int32_t(100*1.5)-2,FR_DEEP);
22256
22257 for(int32_t i=0; i<192; i++)
22258 {
22259 int32_t px2 = d->x+int32_t(((i&15)<<3)*1.5)+8;
22260 int32_t py2 = d->y+int32_t(((i>>4)<<3)*1.5)+8+2;
22261 rectfill(screen,px2,py2,px2+(mul-1),py2+(mul-1),i);
22262 }
22263
22264 break;
22265 }
22266
22267 return D_O_K;
22268 }
22269
22270
22271 int32_t onMiscColors()
22272 {
22273 char buf[17][3];
22274 byte *si = &(QMisc.colors.text);
22275 misccolors_dlg[0].dp2=get_zc_font(font_lfont);
22276
22277 for(int32_t i=0; i<16; i++)
22278 {
22279 sprintf(buf[i],"%02X",*(si++));
22280 sprintf(buf[16], "%02X", QMisc.colors.msgtext);
22281 misccolors_dlg[i+20].dp = buf[i];
22282 misccolors_dlg[55].dp = buf[16];
22283 }
22284
22285 large_dialog(misccolors_dlg);
22286
22287 if(do_zqdialog(misccolors_dlg,0)==52)
22288 {
22289 saved=false;
22290 si = &(QMisc.colors.text);
22291
22292 for(int32_t i=0; i<16; i++)
22293 {
22294 *si = zc_xtoi(buf[i]);
22295 ++si;
22296 }
22297
22298 QMisc.colors.msgtext = zc_xtoi(buf[16]);
22299 }
22300
22301 return D_O_K;
22302 }
22303
22304 // **** Palette cycling ****
22305
22306 static int32_t palclk[3];
22307 static int32_t palpos[3];
22308
22309 33 void reset_pal_cycling()
22310 {
22311
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 33 times.
132 for(int32_t i=0; i<3; i++)
22312 99 palclk[i]=palpos[i]=0;
22313 33 }
22314
22315 void cycle_palette()
22316 {
22317 if(!get_qr(qr_FADE))
22318 return;
22319
22320 int32_t level = Map.CurrScr()->color;
22321 bool refreshpal = false;
22322
22323 for(int32_t i=0; i<3; i++)
22324 {
22325 palcycle c = QMisc.cycles[level][i];
22326
22327 if(c.count&0xF0)
22328 {
22329 if(++palclk[i] >= c.speed)
22330 {
22331 palclk[i]=0;
22332
22333 if(++palpos[i] >= (c.count>>4))
22334 palpos[i]=0;
22335
22336 byte *si = colordata + CSET(level*pdLEVEL+poFADE1+1+palpos[i])*3;
22337
22338 si += (c.first&15)*3;
22339
22340 for(int32_t col=c.first&15; col<=(c.count&15); col++)
22341 {
22342 RAMpal[CSET(c.first>>4)+col] = _RGB(si);
22343 si+=3;
22344 }
22345
22346 refreshpal = true;
22347 }
22348 }
22349 }
22350
22351 if(refreshpal)
22352 {
22353 rebuild_trans_table();
22354 zc_set_palette_range(RAMpal,0,192,false);
22355 }
22356 }
22357
22358
22359 void doHelp()
22360 {
22361 do_box_edit(helpstr, "ZQuest Help", true, true);
22362 }
22363
22364 int32_t onHelp()
22365 {
22366 restore_mouse();
22367 doHelp();
22368 return D_O_K;
22369 }
22370
22371 void doZstringshelp()
22372 {
22373 do_box_edit(zstringshelpstr, "ZStrings Help", true, true);
22374 }
22375
22376 int32_t onZstringshelp()
22377 {
22378 restore_mouse();
22379 doZstringshelp();
22380 return D_O_K;
22381 }
22382
22383 static DIALOG layerdata_dlg[] =
22384 {
22385 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
22386 { jwin_win_proc, 16-12, 20+32, 288+1+24, 200+1-32-16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Layer Data", NULL, NULL },
22387 { jwin_button_proc, 170, 180, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
22388 { jwin_button_proc, 90, 180, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
22389 // 3
22390 { jwin_rtext_proc, 72, 88, 40, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Map:", NULL, NULL },
22391 { jwin_rtext_proc, 72, 88+18, 48, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
22392 { jwin_rtext_proc, 72, 88+36, 56, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Transparent:", NULL, NULL },
22393 { jwin_ctext_proc, 89, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "1", NULL, NULL },
22394 { jwin_ctext_proc, 89+40, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "2", NULL, NULL },
22395 { jwin_ctext_proc, 89+80, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "3", NULL, NULL },
22396 { jwin_ctext_proc, 89+120, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "4", NULL, NULL },
22397 { jwin_ctext_proc, 89+160, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "5", NULL, NULL },
22398 { jwin_ctext_proc, 89+200, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "6", NULL, NULL },
22399
22400 //12
22401 { jwin_edit_proc, 76, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
22402 { d_hexedit_proc, 76, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
22403 { jwin_check_proc, 76, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
22404
22405 { jwin_edit_proc, 76+40, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
22406 { d_hexedit_proc, 76+40, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
22407 { jwin_check_proc, 76+40, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
22408
22409 { jwin_edit_proc, 76+80, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
22410 { d_hexedit_proc, 76+80, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
22411 { jwin_check_proc, 76+80, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
22412
22413 { jwin_edit_proc, 76+120, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
22414 { d_hexedit_proc, 76+120, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
22415 { jwin_check_proc, 76+120, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
22416
22417 { jwin_edit_proc, 76+160, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
22418 { d_hexedit_proc, 76+160, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
22419 { jwin_check_proc, 76+160, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
22420
22421 { jwin_edit_proc, 76+200, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
22422 { d_hexedit_proc, 76+200, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
22423 { jwin_check_proc, 76+200, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
22424
22425 //30
22426 { jwin_button_proc, 76, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
22427 { jwin_button_proc, 76+40, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
22428 { jwin_button_proc, 76+80, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
22429 { jwin_button_proc, 76+120, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
22430 { jwin_button_proc, 76+160, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
22431 { jwin_button_proc, 76+200, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
22432
22433 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
22434 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
22435
22436 };
22437
22438 int32_t edit_layers(mapscr* tempscr)
22439 {
22440 char buf[6][2][8];
22441 layerdata_dlg[0].dp2 = get_zc_font(font_lfont);
22442
22443 for(int32_t x=0; x<6; x++)
22444 {
22445 sprintf(buf[x][0],"%d",tempscr->layermap[x]);
22446 sprintf(buf[x][1],"%02X",tempscr->layerscreen[x]);
22447 }
22448
22449 for(int32_t x=0; x<6; x++)
22450 {
22451 for(int32_t y=0; y<2; y++)
22452 {
22453 layerdata_dlg[(x*3)+y+12].dp = buf[x][y];
22454 }
22455 }
22456
22457 for(int32_t x=0; x<6; x++)
22458 {
22459 layerdata_dlg[(x*3)+2+12].flags = (tempscr->layeropacity[x]<255) ? D_SELECTED : 0;
22460 }
22461
22462 large_dialog(layerdata_dlg);
22463
22464 int32_t ret=do_zqdialog(layerdata_dlg,0);
22465
22466 if(ret>=2)
22467 {
22468 for(int32_t x=0; x<6; x++)
22469 {
22470
22471 tempscr->layermap[x]=atoi(buf[x][0]);
22472
22473 if(tempscr->layermap[x]>map_count)
22474 {
22475 tempscr->layermap[x]=0;
22476 }
22477
22478 tempscr->layerscreen[x]=zc_xtoi(buf[x][1]);
22479
22480 if(zc_xtoi(buf[x][1])>=MAPSCRS)
22481 {
22482 tempscr->layerscreen[x]=0;
22483 }
22484
22485 // tempscr->layeropacity[x]=layerdata_dlg[(x*9)+8+19].flags & D_SELECTED ? 128:255;
22486 tempscr->layeropacity[x]=layerdata_dlg[(x*3)+2+12].flags & D_SELECTED ? 128:255;
22487 }
22488
22489 // } else if (ret>72&&ret<79) {
22490 // return (ret-72);
22491 }
22492
22493 return ret;
22494 }
22495
22496 static DIALOG autolayer_dlg[] =
22497 {
22498 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
22499 { jwin_win_proc, 64, 32+48, 192+1, 184+1-64, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Autolayer Setup", NULL, NULL },
22500 { jwin_text_proc, 76, 56+48, 136, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map for layer ?: ", NULL, NULL },
22501 { jwin_edit_proc, 212, 56+48, 32, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
22502 { jwin_check_proc, 76, 56+18+48, 153, 8, vc(14), vc(1), 0, D_EXIT, 1, 0, (void *) "Only Blank Screens", NULL, NULL },
22503 { jwin_button_proc, 90, 188-12, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
22504
22505 //5
22506 { jwin_button_proc, 170, 188-12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
22507 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
22508 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
22509 { jwin_check_proc, 76, 56+28+48, 153, 8, vc(14), vc(1), 0, D_EXIT, 1, 0, (void *) "Only Blank Layers", NULL, NULL },
22510 { jwin_check_proc, 76, 56+38+48, 153, 8, vc(14), vc(1), 0, D_EXIT, 1, 0, (void *) "Overwrite Layers", NULL, NULL },
22511
22512 //10
22513 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
22514 };
22515 enum
22516 {
22517 autolyr_blankscreens,
22518 autolyr_blanklayers,
22519 autolyr_any
22520 };
22521 void autolayer(mapscr* tempscr, int32_t layer, int32_t al[6][3])
22522 {
22523 char tbuf[80],mlayer[80];
22524 autolayer_dlg[0].dp2=get_zc_font(font_lfont);
22525 sprintf(tbuf, "Map for layer %d: ", layer+1);
22526 autolayer_dlg[1].dp=tbuf;
22527 sprintf(mlayer, "%d", tempscr->layermap[layer]);
22528 autolayer_dlg[2].dp=mlayer;
22529
22530 large_dialog(autolayer_dlg);
22531 int ret, sel = 8, fl = autolyr_blanklayers;
22532 bool running = true;
22533 do
22534 {
22535 SETFLAG(autolayer_dlg[3].flags, D_SELECTED, sel==3);
22536 SETFLAG(autolayer_dlg[8].flags, D_SELECTED, sel==8);
22537 SETFLAG(autolayer_dlg[9].flags, D_SELECTED, sel==9);
22538 switch(ret=do_zqdialog(autolayer_dlg,0))
22539 {
22540 case 4: //OK
22541 {
22542 int32_t lmap=vbound(atoi(mlayer),0,Map.getMapCount());
22543 al[layer][0]=lmap;
22544 tempscr->layermap[layer]=lmap;
22545 tempscr->layerscreen[layer]=Map.getCurrScr();
22546 al[layer][1]=fl;
22547 al[layer][2]=1;
22548 running = false;
22549 break;
22550 }
22551 case 0: case 5: //cancel
22552 running = false;
22553 break;
22554 case 3:
22555 sel = ret;
22556 fl = autolyr_blankscreens;
22557 break;
22558 case 8:
22559 sel = ret;
22560 fl = autolyr_blanklayers;
22561 break;
22562 case 9:
22563 sel = ret;
22564 fl = autolyr_any;
22565 break;
22566 }
22567 }
22568 while(ret != 0 && ret != 4 && ret != 5);
22569 }
22570
22571 int32_t onLayers()
22572 {
22573 mapscr tempscr=*Map.CurrScr();
22574 int32_t al[6][3]; //autolayer[layer][0=map, 1=autolyr_ type, 2=bool go]
22575
22576 for(int32_t i=0; i<6; i++)
22577 {
22578 al[i][0]=tempscr.layermap[i];
22579 al[i][1]=0;
22580 al[i][2]=0;
22581 }
22582
22583 int32_t ret;
22584
22585 do
22586 {
22587 ret=edit_layers(&tempscr);
22588
22589 if(ret>2) //autolayer button
22590 {
22591 autolayer(&tempscr, ret-30, al);
22592 }
22593 }
22594 while(ret>2); //autolayer button
22595
22596 if(ret==2) //OK
22597 {
22598 saved=false;
22599 TheMaps[Map.getCurrMap()*MAPSCRS+Map.getCurrScr()]=tempscr;
22600
22601 for(int32_t i=0; i<6; i++)
22602 {
22603 int32_t tm=tempscr.layermap[i]-1;
22604 int32_t ts=tempscr.layerscreen[i];
22605
22606 if(al[i][2])
22607 {
22608 map_autolayers[Map.getCurrMap()*6+i] = al[i][0];
22609 for(int32_t j=0; j<128; j++)
22610 {
22611 auto& curmapscr = TheMaps[Map.getCurrMap()*MAPSCRS+j];
22612 if(al[i][1] == autolyr_blankscreens && (curmapscr.valid&mVALID))
22613 continue;
22614 else if(al[i][1] == autolyr_blanklayers && curmapscr.layermap[i])
22615 continue;
22616
22617 curmapscr.layermap[i]=al[i][0];
22618 curmapscr.layerscreen[i]=al[i][0]?j:0;
22619 }
22620 }
22621 }
22622 }
22623
22624 // Check that the working layer wasn't just disabled
22625 if(CurrentLayer>0 && tempscr.layermap[CurrentLayer-1]==0)
22626 CurrentLayer=0;
22627
22628 return D_O_K;
22629 }
22630
22631
22632 char *itoa(int32_t i)
22633 {
22634 static char itoaret[500];
22635 sprintf(itoaret, "%d", i);
22636 return itoaret;
22637 }
22638
22639 20 void fps_callback()
22640 {
22641 20 lastfps=framecnt;
22642 20 framecnt=0;
22643 20 }
22644
22645 END_OF_FUNCTION(fps_callback)
22646
22647 //uint32_t col_diff[3*128];
22648 /*
22649 void bestfit_init(void)
22650 {
22651 int32_t i;
22652
22653 for (i=1; i<64; i++)
22654
22655 {
22656 int32_t k = i * i;
22657 col_diff[0 +i] = col_diff[0 +128-i] = k * (59 * 59);
22658 col_diff[128+i] = col_diff[128+128-i] = k * (30 * 30);
22659 col_diff[256+i] = col_diff[256+128-i] = k * (11 * 11);
22660 }
22661 }
22662 */
22663 21 void create_rgb_table2(RGB_MAP *table, AL_CONST PALETTE pal_8bit, void (*callback)(int32_t pos))
22664 {
22665 #define UNUSED 65535
22666 #define LAST 65532
22667
22668 // Allegro has been modified to use an 8 bit palette, but this method and RGB_MAP still use 6 bit.
22669 PALETTE pal;
22670
2/2
✓ Branch 0 taken 5376 times.
✓ Branch 1 taken 21 times.
5397 for (int i = 0; i < 256; i++)
22671 {
22672 5376 pal[i] = pal_8bit[i];
22673 5376 pal[i].r /= 4;
22674 5376 pal[i].g /= 4;
22675 5376 pal[i].b /= 4;
22676 5376 }
22677
22678 /* macro add adds to single linked list */
22679 #define add(i) (next[(i)] == UNUSED ? (next[(i)] = LAST, \
22680 (first != LAST ? (next[last] = (i)) : (first = (i))), \
22681 (last = (i))) : 0)
22682
22683 /* same but w/o checking for first element */
22684 #define add1(i) (next[(i)] == UNUSED ? (next[(i)] = LAST, \
22685 next[last] = (i), \
22686 (last = (i))) : 0)
22687 /* calculates distance between two colors */
22688 #define dist(a1, a2, a3, b1, b2, b3) \
22689 (col_diff[ ((a2) - (b2)) & 0x7F] + \
22690 (col_diff + 128)[((a1) - (b1)) & 0x7F] + \
22691 (col_diff + 256)[((a3) - (b3)) & 0x7F])
22692
22693 /* converts r,g,b to position in array and back */
22694 #define pos(r, g, b) \
22695 (((r) / 2) * 32 * 32 + ((g) / 2) * 32 + ((b) / 2))
22696
22697 #define depos(pal, r, g, b) \
22698 ((b) = ((pal) & 31) * 2, \
22699 (g) = (((pal) >> 5) & 31) * 2, \
22700 (r) = (((pal) >> 10) & 31) * 2)
22701
22702 /* is current color better than pal1? */
22703 #define better(r1, g1, b1, pal1) \
22704 (((int32_t)dist((r1), (g1), (b1), \
22705 (pal1).r, (pal1).g, (pal1).b)) > (int32_t)dist2)
22706
22707 /* checking of position */
22708 #define dopos(rp, gp, bp, ts) \
22709 if ((rp > -1 || r > 0) && (rp < 1 || r < 61) && \
22710 (gp > -1 || g > 0) && (gp < 1 || g < 61) && \
22711 (bp > -1 || b > 0) && (bp < 1 || b < 61)) \
22712 { \
22713 i = first + rp * 32 * 32 + gp * 32 + bp; \
22714 if (!data[i]) \
22715 { \
22716 data[i] = val; \
22717 add1(i); \
22718 } \
22719 else if ((ts) && (data[i] != val)) \
22720 { \
22721 dist2 = (rp ? (col_diff+128)[(r+2*rp-pal[val].r) & 0x7F] : r2) + \
22722 (gp ? (col_diff )[(g+2*gp-pal[val].g) & 0x7F] : g2) + \
22723 (bp ? (col_diff+256)[(b+2*bp-pal[val].b) & 0x7F] : b2); \
22724 if (better((r+2*rp), (g+2*gp), (b+2*bp), pal[data[i]])) \
22725 { \
22726 data[i] = val; \
22727 add1(i); \
22728 } \
22729 } \
22730 }
22731
22732 int32_t i, curr, r, g, b, val, dist2;
22733 uint32_t r2, g2, b2;
22734 uint16_t next[32*32*32];
22735 uint8_t *data;
22736 21 int32_t first = LAST;
22737 21 int32_t last = LAST;
22738 21 int32_t count = 0;
22739 21 int32_t cbcount = 0;
22740
22741 #define AVERAGE_COUNT 18000
22742
22743
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 10 times.
21 if(col_diff[1] == 0)
22744 11 bestfit_init();
22745
22746 21 memset(next, 255, sizeof(next));
22747 21 memset(table->data, 0, sizeof(char)*32*32*32);
22748
22749
22750 21 data = (uint8_t *)table->data;
22751
22752 /* add starting seeds for floodfill */
22753
2/2
✓ Branch 0 taken 5355 times.
✓ Branch 1 taken 21 times.
5376 for(i=1; i<PAL_SIZE; i++)
22754 {
22755 5355 curr = pos(pal[i].r, pal[i].g, pal[i].b);
22756
22757
2/2
✓ Branch 0 taken 4053 times.
✓ Branch 1 taken 1302 times.
5355 if(next[curr] == UNUSED)
22758 {
22759 1302 data[curr] = i;
22760
3/4
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1281 times.
✓ Branch 3 taken 21 times.
1302 add(curr);
22761 1302 }
22762 5355 }
22763
22764 /* main floodfill: two versions of loop for faster growing in blue axis */
22765 // while (first != LAST) {
22766
2/2
✓ Branch 0 taken 450575 times.
✓ Branch 1 taken 21 times.
450596 while(first < LAST)
22767 {
22768 450575 depos(first, r, g, b);
22769
22770 /* calculate distance of current color */
22771 450575 val = data[first];
22772 450575 r2 = (col_diff+128)[((pal[val].r)-(r)) & 0x7F];
22773 450575 g2 = (col_diff)[((pal[val].g)-(g)) & 0x7F];
22774 450575 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7F];
22775
22776 /* try to grow to all directions */
22777 #ifdef _MSC_VER
22778 #pragma warning(disable:4127)
22779 #endif
22780
11/12
✓ Branch 0 taken 14797 times.
✓ Branch 1 taken 435778 times.
✓ Branch 2 taken 418414 times.
✓ Branch 3 taken 17364 times.
✓ Branch 4 taken 17364 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 349903 times.
✓ Branch 7 taken 68511 times.
✓ Branch 8 taken 19107 times.
✓ Branch 9 taken 49404 times.
✓ Branch 10 taken 30562 times.
✓ Branch 11 taken 18842 times.
868989 dopos(0, 0, 1, 1);
22781
11/12
✓ Branch 0 taken 13307 times.
✓ Branch 1 taken 437268 times.
✓ Branch 2 taken 421926 times.
✓ Branch 3 taken 15342 times.
✓ Branch 4 taken 15342 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 367287 times.
✓ Branch 7 taken 54639 times.
✓ Branch 8 taken 21549 times.
✓ Branch 9 taken 33090 times.
✓ Branch 10 taken 21770 times.
✓ Branch 11 taken 11320 times.
872501 dopos(0, 0,-1, 1);
22782
11/12
✓ Branch 0 taken 14382 times.
✓ Branch 1 taken 436193 times.
✓ Branch 2 taken 424908 times.
✓ Branch 3 taken 11285 times.
✓ Branch 4 taken 11285 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 347042 times.
✓ Branch 7 taken 77866 times.
✓ Branch 8 taken 50354 times.
✓ Branch 9 taken 27512 times.
✓ Branch 10 taken 17286 times.
✓ Branch 11 taken 10226 times.
875483 dopos(1, 0, 0, 1);
22783
11/12
✓ Branch 0 taken 14499 times.
✓ Branch 1 taken 436076 times.
✓ Branch 2 taken 424084 times.
✓ Branch 3 taken 11992 times.
✓ Branch 4 taken 11992 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 349660 times.
✓ Branch 7 taken 74424 times.
✓ Branch 8 taken 49118 times.
✓ Branch 9 taken 25306 times.
✓ Branch 10 taken 16008 times.
✓ Branch 11 taken 9298 times.
874659 dopos(-1, 0, 0, 1);
22784
11/12
✓ Branch 0 taken 14539 times.
✓ Branch 1 taken 436036 times.
✓ Branch 2 taken 391471 times.
✓ Branch 3 taken 44565 times.
✓ Branch 4 taken 44565 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 290643 times.
✓ Branch 7 taken 100828 times.
✓ Branch 8 taken 83046 times.
✓ Branch 9 taken 17782 times.
✓ Branch 10 taken 11492 times.
✓ Branch 11 taken 6290 times.
842046 dopos(0, 1, 0, 1);
22785
11/12
✓ Branch 0 taken 13124 times.
✓ Branch 1 taken 437451 times.
✓ Branch 2 taken 399232 times.
✓ Branch 3 taken 38219 times.
✓ Branch 4 taken 38219 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 299384 times.
✓ Branch 7 taken 99848 times.
✓ Branch 8 taken 85123 times.
✓ Branch 9 taken 14725 times.
✓ Branch 10 taken 9189 times.
✓ Branch 11 taken 5536 times.
849807 dopos(0,-1, 0, 1);
22786 #ifdef _MSC_VER
22787 #pragma warning(default:4127)
22788 #endif
22789
22790 /* faster growing of blue direction */
22791
4/4
✓ Branch 0 taken 437268 times.
✓ Branch 1 taken 13307 times.
✓ Branch 2 taken 21549 times.
✓ Branch 3 taken 415719 times.
450575 if((b > 0) && (data[first-1] == val))
22792 {
22793 415719 b -= 2;
22794 415719 first--;
22795 415719 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7F];
22796
22797 #ifdef _MSC_VER
22798 #pragma warning(disable:4127)
22799 #endif
22800
5/6
✓ Branch 0 taken 13508 times.
✓ Branch 1 taken 402211 times.
✓ Branch 2 taken 366059 times.
✓ Branch 3 taken 36152 times.
✓ Branch 4 taken 36152 times.
✗ Branch 5 not taken.
781778 dopos(-1, 0, 0, 0);
22801
5/6
✓ Branch 0 taken 13364 times.
✓ Branch 1 taken 402355 times.
✓ Branch 2 taken 365610 times.
✓ Branch 3 taken 36745 times.
✓ Branch 4 taken 36745 times.
✗ Branch 5 not taken.
781329 dopos(1, 0, 0, 0);
22802
5/6
✓ Branch 0 taken 12197 times.
✓ Branch 1 taken 403522 times.
✓ Branch 2 taken 355860 times.
✓ Branch 3 taken 47662 times.
✓ Branch 4 taken 47662 times.
✗ Branch 5 not taken.
771579 dopos(0,-1, 0, 0);
22803
5/6
✓ Branch 0 taken 13551 times.
✓ Branch 1 taken 402168 times.
✓ Branch 2 taken 336590 times.
✓ Branch 3 taken 65578 times.
✓ Branch 4 taken 65578 times.
✗ Branch 5 not taken.
752309 dopos(0, 1, 0, 0);
22804 #ifdef _MSC_VER
22805 #pragma warning(default:4127)
22806 #endif
22807
22808 415719 first++;
22809 415719 }
22810
22811 /* get next from list */
22812 450575 i = first;
22813 450575 first = next[first];
22814 450575 next[i] = UNUSED;
22815
22816 /* second version of loop */
22817 // if (first != LAST) {
22818
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 450564 times.
450575 if(first < LAST)
22819 {
22820
22821 450564 depos(first, r, g, b);
22822
22823 450564 val = data[first];
22824 450564 r2 = (col_diff+128)[((pal[val].r)-(r)) & 0x7F];
22825 450564 g2 = (col_diff)[((pal[val].g)-(g)) & 0x7F];
22826 450564 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7F];
22827
22828 #ifdef _MSC_VER
22829 #pragma warning(disable:4127)
22830 #endif
22831
11/12
✓ Branch 0 taken 14370 times.
✓ Branch 1 taken 436194 times.
✓ Branch 2 taken 415857 times.
✓ Branch 3 taken 20337 times.
✓ Branch 4 taken 20337 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 347408 times.
✓ Branch 7 taken 68449 times.
✓ Branch 8 taken 19063 times.
✓ Branch 9 taken 49386 times.
✓ Branch 10 taken 30486 times.
✓ Branch 11 taken 18900 times.
866421 dopos(0, 0, 1, 1);
22832
11/12
✓ Branch 0 taken 13244 times.
✓ Branch 1 taken 437320 times.
✓ Branch 2 taken 424306 times.
✓ Branch 3 taken 13014 times.
✓ Branch 4 taken 13014 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 369421 times.
✓ Branch 7 taken 54885 times.
✓ Branch 8 taken 21923 times.
✓ Branch 9 taken 32962 times.
✓ Branch 10 taken 21778 times.
✓ Branch 11 taken 11184 times.
874870 dopos(0, 0,-1, 1);
22833
11/12
✓ Branch 0 taken 14583 times.
✓ Branch 1 taken 435981 times.
✓ Branch 2 taken 424300 times.
✓ Branch 3 taken 11681 times.
✓ Branch 4 taken 11681 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 346291 times.
✓ Branch 7 taken 78009 times.
✓ Branch 8 taken 50641 times.
✓ Branch 9 taken 27368 times.
✓ Branch 10 taken 17229 times.
✓ Branch 11 taken 10139 times.
874864 dopos(1, 0, 0, 1);
22834
11/12
✓ Branch 0 taken 14345 times.
✓ Branch 1 taken 436219 times.
✓ Branch 2 taken 424380 times.
✓ Branch 3 taken 11839 times.
✓ Branch 4 taken 11839 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 349785 times.
✓ Branch 7 taken 74595 times.
✓ Branch 8 taken 49492 times.
✓ Branch 9 taken 25103 times.
✓ Branch 10 taken 16289 times.
✓ Branch 11 taken 8814 times.
874944 dopos(-1, 0, 0, 1);
22835
11/12
✓ Branch 0 taken 14476 times.
✓ Branch 1 taken 436088 times.
✓ Branch 2 taken 392433 times.
✓ Branch 3 taken 43655 times.
✓ Branch 4 taken 43655 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 292163 times.
✓ Branch 7 taken 100270 times.
✓ Branch 8 taken 82655 times.
✓ Branch 9 taken 17615 times.
✓ Branch 10 taken 11555 times.
✓ Branch 11 taken 6060 times.
842997 dopos(0, 1, 0, 1);
22836
11/12
✓ Branch 0 taken 13010 times.
✓ Branch 1 taken 437554 times.
✓ Branch 2 taken 399976 times.
✓ Branch 3 taken 37578 times.
✓ Branch 4 taken 37578 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 299995 times.
✓ Branch 7 taken 99981 times.
✓ Branch 8 taken 85368 times.
✓ Branch 9 taken 14613 times.
✓ Branch 10 taken 9367 times.
✓ Branch 11 taken 5246 times.
850540 dopos(0,-1, 0, 1);
22837 #ifdef _MSC_VER
22838 #pragma warning(default:4127)
22839 #endif
22840
22841
4/4
✓ Branch 0 taken 436194 times.
✓ Branch 1 taken 14370 times.
✓ Branch 2 taken 19063 times.
✓ Branch 3 taken 417131 times.
450564 if((b < 61) && (data[first + 1] == val))
22842 {
22843 417131 b += 2;
22844 417131 first++;
22845 417131 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7f];
22846 #ifdef _MSC_VER
22847 #pragma warning(disable:4127)
22848 #endif
22849
5/6
✓ Branch 0 taken 13397 times.
✓ Branch 1 taken 403734 times.
✓ Branch 2 taken 361902 times.
✓ Branch 3 taken 41832 times.
✓ Branch 4 taken 41832 times.
✗ Branch 5 not taken.
779033 dopos(-1, 0, 0, 0);
22850
5/6
✓ Branch 0 taken 13497 times.
✓ Branch 1 taken 403634 times.
✓ Branch 2 taken 354721 times.
✓ Branch 3 taken 48913 times.
✓ Branch 4 taken 48913 times.
✗ Branch 5 not taken.
771852 dopos(1, 0, 0, 0);
22851
5/6
✓ Branch 0 taken 12034 times.
✓ Branch 1 taken 405097 times.
✓ Branch 2 taken 338219 times.
✓ Branch 3 taken 66878 times.
✓ Branch 4 taken 66878 times.
✗ Branch 5 not taken.
755350 dopos(0,-1, 0, 0);
22852
5/6
✓ Branch 0 taken 13617 times.
✓ Branch 1 taken 403514 times.
✓ Branch 2 taken 337319 times.
✓ Branch 3 taken 66195 times.
✓ Branch 4 taken 66195 times.
✗ Branch 5 not taken.
754450 dopos(0, 1, 0, 0);
22853 #ifdef _MSC_VER
22854 #pragma warning(default:4127)
22855 #endif
22856
22857 417131 first--;
22858 417131 }
22859
22860 450564 i = first;
22861 450564 first = next[first];
22862 450564 next[i] = UNUSED;
22863 450564 }
22864
22865 450575 count++;
22866
22867
2/2
✓ Branch 0 taken 445178 times.
✓ Branch 1 taken 5397 times.
450575 if(count == (cbcount+1)*AVERAGE_COUNT/256)
22868 {
22869
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 5376 times.
5397 if(cbcount < 256)
22870 {
22871
1/2
✓ Branch 0 taken 5376 times.
✗ Branch 1 not taken.
5376 if(callback)
22872 callback(cbcount);
22873
22874 5376 cbcount++;
22875 5376 }
22876 5397 }
22877
22878 }
22879
22880 /* only the transparent (pink) color can be mapped to index 0 */
22881
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21 if((pal[0].r == 63) && (pal[0].g == 0) && (pal[0].b == 63))
22882 table->data[31][0][31] = 0;
22883
22884
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(callback)
22885 while(cbcount < 256)
22886 callback(cbcount++);
22887 21 }
22888
22889 21 void rebuild_trans_table()
22890 {
22891 21 create_rgb_table2(&zq_rgb_table, RAMpal, NULL);
22892 21 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
22893 21 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
22894
22895
2/2
✓ Branch 0 taken 5376 times.
✓ Branch 1 taken 21 times.
5397 for(int32_t q=0; q<PAL_SIZE; q++)
22896 {
22897 5376 trans_table2.data[0][q] = q;
22898 5376 trans_table2.data[q][q] = q;
22899 5376 }
22900 21 }
22901
22902 int32_t isFullScreen()
22903 {
22904 return !is_windowed_mode();
22905 }
22906
22907 void hit_close_button()
22908 {
22909 close_button_quit=true;
22910 return;
22911 }
22912
22913 extern bool dirty_screen;
22914
22915 void anim_hw_screen(bool force)
22916 {
22917 // if (force || myvsync)
22918 {
22919 ++cpoolbrush_index;
22920
22921 if(prv_mode)
22922 {
22923 if(Map.get_prvtime())
22924 {
22925 Map.set_prvtime(Map.get_prvtime()-1);
22926
22927 if(!Map.get_prvtime())
22928 {
22929 prv_warp=1;
22930 }
22931 }
22932 }
22933 if(AnimationOn)
22934 {
22935 animate_combos();
22936 update_freeform_combos();
22937 }
22938
22939 if(CycleOn)
22940 cycle_palette();
22941
22942 animate_coords();
22943 update_hw_screen();
22944 }
22945 }
22946
22947 void custom_vsync()
22948 {
22949 anim_hw_screen(true);
22950 }
22951
22952 void switch_out()
22953 {
22954 zcmusic_pause(zcmusic, ZCM_PAUSE);
22955 zc_midi_pause();
22956 }
22957
22958 void switch_in()
22959 {
22960 if(exiting_program)
22961 return;
22962 zcmusic_pause(zcmusic, ZCM_RESUME);
22963 zc_midi_resume();
22964 }
22965
22966 void Z_eventlog(const char *format,...)
22967 {
22968 format=format; //to prevent a compiler warning
22969 }
22970
22971 int32_t get_currdmap()
22972 {
22973 return zinit.start_dmap;
22974 }
22975
22976 int32_t get_dlevel()
22977 {
22978 return DMaps[zinit.start_dmap].level;
22979 }
22980
22981 int32_t get_currscr()
22982 {
22983 return Map.getCurrScr();
22984 }
22985
22986 int32_t get_currmap()
22987 {
22988 return Map.getCurrMap();
22989 }
22990
22991 int32_t get_homescr()
22992 {
22993 return DMaps[zinit.start_dmap].cont;
22994 }
22995
22996 int get_screen_for_world_xy(int x, int y)
22997 {
22998 return -1;
22999 }
23000
23001 int current_item(int item_type, bool checkmagic, bool jinx_check, bool check_bunny)
23002 {
23003 //TODO remove as special case?? -DD
23004 if(item_type==itype_shield)
23005 {
23006 return 2;
23007 }
23008
23009 int id = current_item_id(item_type, checkmagic, jinx_check, check_bunny);
23010 return id > -1 ? itemsbuf[id].fam_type : 0;
23011 }
23012
23013 int current_item_power(int itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
23014 {
23015 if (game)
23016 {
23017 int result = current_item_id(itemtype, checkmagic, jinx_check, check_bunny);
23018 return (result<0) ? 0 : itemsbuf[result].power;
23019 }
23020 return 1;
23021 }
23022
23023 int32_t current_item_id(int32_t itemtype, bool, bool, bool)
23024 {
23025 if (game)
23026 {
23027 int32_t result = -1;
23028 int32_t highestlevel = -1;
23029
23030 for (int32_t i = 0; i < MAXITEMS; i++)
23031 {
23032 if ((zq_ignore_item_ownership || game->get_item(i)) && itemsbuf[i].family == itemtype)
23033 {
23034 if (itemsbuf[i].fam_type >= highestlevel)
23035 {
23036 highestlevel = itemsbuf[i].fam_type;
23037 result = i;
23038 }
23039 }
23040 }
23041 return result;
23042 }
23043 for(int32_t i=0; i<MAXITEMS; i++)
23044 {
23045 if(itemsbuf[i].family==itemtype)
23046 return i;
23047 }
23048
23049 return -1;
23050 }
23051
23052
23053 bool can_use_item(int32_t item_type, int32_t item)
23054 {
23055 //these are here to bypass compiler warnings about unused arguments
23056 item_type=item_type;
23057 item=item;
23058
23059 return true;
23060 }
23061
23062 bool has_item(int32_t item_type, int32_t it)
23063 {
23064 //these are here to bypass compiler warnings about unused arguments
23065 item_type=item_type;
23066 it=it;
23067
23068 return true;
23069 }
23070
23071 int32_t get_bmaps(int32_t si)
23072 {
23073 //these are here to bypass compiler warnings about unused arguments
23074 si=si;
23075
23076 return 255;
23077 }
23078
23079 bool no_subscreen()
23080 {
23081 return false;
23082 }
23083
23084 12 static void allocate_crap()
23085 {
23086 12 filepath=(char*)malloc(2048);
23087 12 datapath=(char*)malloc(2048);
23088 12 midipath=(char*)malloc(2048);
23089 12 imagepath=(char*)malloc(2048);
23090 12 tmusicpath=(char*)malloc(2048);
23091 12 last_timed_save=(char*)malloc(2048);
23092
23093
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!filepath || !datapath || !imagepath || !midipath || !tmusicpath || !last_timed_save)
23094 {
23095 Z_error_fatal("Error: no memory for file paths!");
23096 }
23097
23098
23099 12 customtunes = (zctune*)malloc(sizeof(zctune)*MAXCUSTOMMIDIS_ZQ);
23100 12 memset(customtunes, 0, sizeof(zctune)*MAXCUSTOMMIDIS_ZQ);
23101
23102
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<MAXCUSTOMMIDIS_ZQ; ++i)
23103 {
23104 3072 customtunes[i].data=NULL;
23105 3072 }
23106
23107
2/2
✓ Branch 0 taken 3024 times.
✓ Branch 1 taken 12 times.
3036 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
23108 {
23109 3024 midi_string[i+4]=customtunes[i].title;
23110 3024 screen_midi_string[i+5]=customtunes[i].title;
23111 3024 }
23112
23113
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<WAV_COUNT; i++)
23114 {
23115
1/4
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3072 if(sfx_string[i]!=NULL) delete sfx_string[i];
23116 3072 customsfxdata[i].data=NULL;
23117 3072 sfx_string[i] = new char[36];
23118 3072 memset(sfx_string[i], 0, 36);
23119 3072 }
23120
23121
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<MAXWPNS; i++)
23122 {
23123
1/4
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3072 if(weapon_string[i]!=NULL) delete weapon_string[i];
23124 3072 weapon_string[i] = new char[64];
23125 3072 memset(weapon_string[i], 0, 64);
23126 3072 }
23127
23128
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<MAXITEMS; i++)
23129 {
23130
1/4
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3072 if(item_string[i]!=NULL) delete item_string[i];
23131 3072 item_string[i] = new char[64];
23132 3072 memset(item_string[i], 0, 64);
23133 3072 }
23134
23135
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
6156 for(int32_t i=0; i<eMAXGUYS; i++)
23136 {
23137
1/4
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6144 if(guy_string[i]!=NULL) delete guy_string[i];
23138 6144 guy_string[i] = new char[64];
23139 6144 memset(guy_string[i], 0, 64);
23140 6144 }
23141
23142
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
6156 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
23143 {
23144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 delete ffscripts[i];
23145
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 ffscripts[i] = new script_data(ScriptType::FFC, i);
23146 6144 }
23147
23148
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
23149 {
23150
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete itemscripts[i];
23151
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 itemscripts[i] = new script_data(ScriptType::Item, i);
23152 3072 }
23153
23154
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
23155 {
23156
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete guyscripts[i];
23157
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 guyscripts[i] = new script_data(ScriptType::NPC, i);
23158 3072 }
23159
23160
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
23161 {
23162
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete screenscripts[i];
23163
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 screenscripts[i] = new script_data(ScriptType::Screen, i);
23164 3072 }
23165
23166
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 12 times.
108 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
23167 {
23168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 delete globalscripts[i];
23169
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 globalscripts[i] = new script_data(ScriptType::Global, i);
23170 96 }
23171
23172
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
23173 {
23174
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 delete playerscripts[i];
23175
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 playerscripts[i] = new script_data(ScriptType::Hero, i);
23176 60 }
23177
23178
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
23179 {
23180
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete lwpnscripts[i];
23181
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
23182 3072 }
23183
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
23184 {
23185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3072 times.
3072 delete ewpnscripts[i];
23186
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
23187 3072 }
23188
23189
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
23190 {
23191
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete dmapscripts[i];
23192
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 dmapscripts[i] = new script_data(ScriptType::DMap, i);
23193 3072 }
23194
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
23195 {
23196
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete itemspritescripts[i];
23197
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
23198 3072 }
23199
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
6156 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
23200 {
23201
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 delete comboscripts[i];
23202
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 comboscripts[i] = new script_data(ScriptType::Combo, i);
23203 6144 }
23204
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
6156 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
23205 {
23206
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 delete genericscripts[i];
23207
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 genericscripts[i] = new script_data(ScriptType::Generic, i);
23208 6144 }
23209
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
23210 {
23211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3072 times.
3072 delete subscreenscripts[i];
23212
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
23213 3072 }
23214 12 }
23215
23216 static void handle_sentry_tags()
23217 {
23218 static bool sentry_first_time = true;
23219
23220 static MapCursor sentry_last_map_cursor;
23221 if (Map.getCursor() != sentry_last_map_cursor || sentry_first_time)
23222 {
23223 sentry_last_map_cursor = Map.getCursor();
23224 zapp_reporting_set_tag("cursor.map", sentry_last_map_cursor.map);
23225 zapp_reporting_set_tag("cursor.screen", sentry_last_map_cursor.screen);
23226 zapp_reporting_set_tag("cursor.viewscr", sentry_last_map_cursor.viewscr);
23227 zapp_reporting_set_tag("cursor.size", sentry_last_map_cursor.size);
23228 }
23229
23230 static bool sentry_last_is_compact;
23231 if (is_compact != sentry_last_is_compact || sentry_first_time)
23232 {
23233 sentry_last_is_compact = is_compact;
23234 zapp_reporting_set_tag("compact", sentry_last_is_compact);
23235 }
23236
23237 sentry_first_time = false;
23238 }
23239
23240 // Removes the top layer encoding from a quest file. See open_quest_file.
23241 // This has zero impact on the contents of the quest file. There should be no way for this to
23242 // break anything.
23243 static void do_unencrypt_qst_command(const char* input_filename, const char* output_filename)
23244 {
23245 // If the file is already an unencrypted packfile, there's nothing to do.
23246 PACKFILE* pf_check = pack_fopen_password(input_filename, F_READ_PACKED, "");
23247 pack_fclose(pf_check);
23248 if (pf_check) return;
23249
23250 int32_t error;
23251 PACKFILE* pf = open_quest_file(&error, input_filename, false);
23252 PACKFILE* pf2 = pack_fopen_password(output_filename, F_WRITE_PACKED, "");
23253 int c;
23254 while ((c = pack_getc(pf)) != EOF)
23255 {
23256 pack_putc(c, pf2);
23257 }
23258 pack_fclose(pf);
23259 pack_fclose(pf2);
23260 clear_quest_tmpfile();
23261 }
23262
23263 // This will remove the PACKFILE compression. Incidentally, it also removes the top encoding layer.
23264 static void do_uncompress_qst_command(const char* input_filename, const char* output_filename)
23265 {
23266 auto unencrypted_result = try_open_maybe_legacy_encoded_file(input_filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
23267 if (unencrypted_result.not_found)
23268 {
23269 printf("qst not found\n");
23270 zq_exit(1);
23271 }
23272 if (!unencrypted_result.compressed && !unencrypted_result.encrypted)
23273 {
23274 // If the file is already an uncompressed file, there's nothing to do but copy it.
23275 fs::copy(input_filename, output_filename);
23276 return;
23277 }
23278
23279 pack_fclose(unencrypted_result.decoded_pf);
23280
23281 int32_t error;
23282 PACKFILE* pf = open_quest_file(&error, input_filename, false);
23283 PACKFILE* pf2 = pack_fopen_password(output_filename, F_WRITE, "");
23284 int c;
23285 while ((c = pack_getc(pf)) != EOF)
23286 {
23287 pack_putc(c, pf2);
23288 }
23289 pack_fclose(pf);
23290 pack_fclose(pf2);
23291 clear_quest_tmpfile();
23292 }
23293
23294 // Copy a quest file by loading and resaving, exactly like if the user did it in the UI.
23295 // Note there could be changes introduced in the loading or saving functions. These are
23296 // typically for compatability, but could possibly be a source of bugs.
23297 3 static void do_copy_qst_command(const char* input_filename, const char* output_filename)
23298 {
23299 3 set_headless_mode();
23300
23301 // We need to init some stuff before loading a quest file will work.
23302 3 int fake_errno = 0;
23303 3 allegro_errno = &fake_errno;
23304 3 get_qst_buffers();
23305
23306 3 int ret = load_quest(input_filename, false);
23307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (ret)
23308 {
23309 zq_exit(ret);
23310 }
23311
23312 3 ret = save_quest(output_filename, false);
23313 3 zq_exit(ret);
23314 3 }
23315
23316 int32_t Awpn=-1, Bwpn=-1, Xwpn = -1, Ywpn = -1;
23317 84 sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations, portals;
23318 int32_t exittimer = 10000, exittimer2 = 100;
23319
23320 1 static bool partial_load_test(const char* test_dir)
23321 {
23322
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 auto classic_path = fs::path(test_dir) / "replays/classic_1st.qst";
23323
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 int ret = load_quest(classic_path.string().c_str(), false);
23324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (ret)
23325 {
23326 printf("failed to load classic_1st.qst: ret == %d\n", ret);
23327 return false;
23328 }
23329
23330 1 int cont = DMaps[0].cont;
23331
23332 // Skip same stuff as used in zq_tiles.cpp for grabbing tiles from a qst.
23333 byte skip_flags[4];
23334
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 26 times.
27 for (int i=0; i<skip_max; ++i)
23335
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 set_bit(skip_flags,i,1);
23336
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 set_bit(skip_flags,skip_tiles,0);
23337
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 set_bit(skip_flags,skip_header,0);
23338 1 zquestheader tempheader{};
23339
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 auto ptux_path = fs::path(test_dir) / "quests/PTUX.qst";
23340
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 ret = loadquest(ptux_path.string().c_str(), &tempheader, &QMisc, customtunes, false, skip_flags);
23341
23342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (ret)
23343 {
23344 printf("failed to load PTUX.qst: ret == %d\n", ret);
23345 return false;
23346 }
23347
23348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (DMaps[0].cont != cont)
23349 {
23350 printf("unexpected modification: DMaps[0].cont == %d, should be %d\n", DMaps[0].cont, cont);
23351 return false;
23352 }
23353
23354 // TODO should run replay. Currently, resaving classic_1st.qst fails its replay (see test_save in test_zeditor.py)
23355
23356 1 return true;
23357 1 }
23358
23359 template <typename ...Params>
23360 [[noreturn]] void FatalConsole(const char *format, Params&&... params)
23361 {
23362 FFCore.ZScriptConsole(CConsoleLoggerEx::COLOR_RED|CConsoleLoggerEx::COLOR_INTENSITY|CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"");
23363 Z_error_fatal(format, std::forward<Params>(params)...);
23364 }
23365
23366 40 static BITMAP* load_asset_bmp(const char* path)
23367 {
23368 40 BITMAP* bmp = load_bmp(path, nullptr);
23369
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if (!bmp)
23370 Z_error_fatal("Failed to load required asset: %s\n", path);
23371 40 return bmp;
23372 }
23373
23374 8 static void load_asset_pal(PALETTE pal, const char* path)
23375 {
23376 8 BITMAP* bmp = load_bmp(path, pal);
23377
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (!bmp)
23378 Z_error_fatal("Failed to load required asset: %s\n", path);
23379 8 }
23380
23381 8 static MIDI* load_asset_midi(const char* path)
23382 {
23383 8 MIDI* midi = load_midi(path);
23384
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (!midi)
23385 Z_error_fatal("Failed to load required asset: %s\n", path);
23386 8 return midi;
23387 }
23388
23389 BITMAP* asset_icons_bmp;
23390 BITMAP* asset_engravings_bmp;
23391 BITMAP* asset_mouse_bmp;
23392 BITMAP* asset_select_bmp;
23393 BITMAP* asset_arrows_bmp;
23394 MIDI* asset_tunes_midi;
23395 PALETTE asset_pal;
23396
23397 8 static void load_assets()
23398 {
23399 8 asset_icons_bmp = load_asset_bmp("assets/editor/icons.bmp");
23400 8 asset_engravings_bmp = load_asset_bmp("assets/editor/engravings.bmp");
23401 8 asset_mouse_bmp = load_asset_bmp("assets/editor/mouse.bmp");
23402 8 asset_select_bmp = load_asset_bmp("assets/editor/select.bmp");
23403 8 asset_arrows_bmp = load_asset_bmp("assets/editor/arrows.bmp");
23404 8 asset_tunes_midi = load_asset_midi("assets/editor/tunes.mid");
23405 8 load_asset_pal(asset_pal, "assets/editor/pal.bmp");
23406 8 }
23407
23408 static bool application_has_loaded;
23409
23410 8 int32_t main(int32_t argc,char **argv)
23411 {
23412 8 int test_zc_arg = used_switch(argc, argv, "-test-zc");
23413
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if (test_zc_arg > 0)
23414 1 set_headless_mode();
23415
23416 8 zalleg_setup_allegro(App::zquest, argc, argv);
23417 8 allocate_crap();
23418
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 set_should_zprint_cb([]() {
23419 return get_qr(qr_SCRIPTERRLOG) || DEVLEVEL > 0;
23420 });
23421
23422 8 int package_arg = used_switch(argc, argv, "-package");
23423
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (package_arg > 0)
23424 {
23425 if (package_arg + 3 > argc)
23426 {
23427 printf("%d\n", argc);
23428 printf("expected -package <game.qst> <package name>\n");
23429 zq_exit(1);
23430 }
23431
23432 const char* input_filename = argv[package_arg + 1];
23433 const char* package_name = argv[package_arg + 2];
23434 if (auto error = package_create(input_filename, package_name))
23435 Z_error_fatal("%s\n", error->c_str());
23436 zq_exit(0);
23437 }
23438
23439 8 int copy_qst_arg = used_switch(argc, argv, "-copy-qst");
23440
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
8 if (copy_qst_arg > 0)
23441 {
23442
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (copy_qst_arg + 3 > argc)
23443 {
23444 printf("%d\n", argc);
23445 printf("expected -copy-qst <input> <output>\n");
23446 zq_exit(1);
23447 }
23448
23449 3 const char* input_filename = argv[copy_qst_arg + 1];
23450 3 const char* output_filename = argv[copy_qst_arg + 2];
23451 3 do_copy_qst_command(input_filename, output_filename);
23452 3 }
23453
23454 8 Z_title("ZQuest Classic Editor, %s", getVersionString());
23455
23456
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!get_qst_buffers())
23457 {
23458 Z_error_fatal("Error");
23459 }
23460
23461 8 undocombobuf.clear();
23462 8 undocombobuf.resize(MAXCOMBOS);
23463
23464
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if((newundotilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
23465 {
23466 Z_error_fatal("Error: no memory for tile undo buffer!");
23467 }
23468
23469 8 memset(newundotilebuf, 0, NEWMAXTILES*sizeof(tiledata));
23470
23471 8 Z_message("Resetting new tile buffer...");
23472 8 newtilebuf = (tiledata*)malloc(NEWMAXTILES*sizeof(tiledata));
23473
23474
2/2
✓ Branch 0 taken 1930500 times.
✓ Branch 1 taken 8 times.
1930508 for(int32_t j=0; j<NEWMAXTILES; j++)
23475 1930500 newtilebuf[j].data=NULL;
23476
23477 8 Z_message("OK\n");
23478
23479 8 zc_srand(time(0));
23480
23481
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
8 if (test_zc_arg > 0)
23482 {
23483 1 set_headless_mode();
23484
23485
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (test_zc_arg + 1 > argc)
23486 {
23487 printf("%d\n", argc);
23488 printf("expected -test-zc <path to test dir>\n");
23489 zq_exit(1);
23490 }
23491
23492 1 const char* test_dir = argv[test_zc_arg + 1];
23493
23494 // We need to init some stuff before loading a quest file will work.
23495 1 int fake_errno = 0;
23496 1 allegro_errno = &fake_errno;
23497 1 get_qst_buffers();
23498
23499 1 bool success = true;
23500
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!partial_load_test(test_dir))
23501 {
23502 success = false;
23503 printf("partial_load_test failed\n");
23504 }
23505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (success)
23506 1 printf("all tests passed\n");
23507 1 zq_exit(success ? 0 : 1);
23508 1 }
23509
23510 8 int unencrypt_qst_arg = used_switch(argc, argv, "-unencrypt-qst");
23511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (unencrypt_qst_arg > 0)
23512 {
23513 if (unencrypt_qst_arg + 3 > argc)
23514 {
23515 printf("%d\n", argc);
23516 printf("expected -unencrypt-qst <input> <output>\n");
23517 zq_exit(1);
23518 }
23519
23520 const char* input_filename = argv[unencrypt_qst_arg + 1];
23521 const char* output_filename = argv[unencrypt_qst_arg + 2];
23522 do_unencrypt_qst_command(input_filename, output_filename);
23523 zq_exit(0);
23524 }
23525
23526 8 int uncompress_qst_arg = used_switch(argc, argv, "-uncompress-qst");
23527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (uncompress_qst_arg > 0)
23528 {
23529 if (uncompress_qst_arg + 3 > argc)
23530 {
23531 printf("%d\n", argc);
23532 printf("expected -uncompress-qst <input> <output>\n");
23533 zq_exit(1);
23534 }
23535
23536 const char* input_filename = argv[uncompress_qst_arg + 1];
23537 const char* output_filename = argv[uncompress_qst_arg + 2];
23538 do_uncompress_qst_command(input_filename, output_filename);
23539 zq_exit(0);
23540 }
23541
23542 8 three_finger_flag=false;
23543
23544 #ifndef __EMSCRIPTEN__
23545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(zc_get_config("zquest","open_debug_console",0))
23546 initConsole();
23547 #endif
23548
23549 LOCK_VARIABLE(lastfps);
23550
23551 LOCK_VARIABLE(framecnt);
23552 LOCK_FUNCTION(fps_callback);
23553
23554
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
23555 {
23556 Z_error_fatal("couldn't allocate timer");
23557 }
23558
23559
23560 LOCK_VARIABLE(dclick_status);
23561 LOCK_VARIABLE(dclick_time);
23562 8 lock_dclick_function();
23563 8 install_int(dclick_check, 20);
23564
23565 8 set_gfx_mode(GFX_TEXT,80,50,0,0);
23566
23567 8 load_assets();
23568
23569 8 Z_message("OK\n");
23570
23571
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 helpstr = util::read_text_file("docs/zquest.txt");
23572
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 zstringshelpstr = util::read_text_file("docs/zstrings.txt");
23573
23574 // loading data files...
23575
23576 8 filepath[0]=temppath[0]=0;
23577
23578 8 const char *default_path="";
23579
23580 8 strcpy(datapath,zc_get_config("zquest",data_path_name,default_path));
23581 8 strcpy(midipath,zc_get_config("zquest",midi_path_name,default_path));
23582 8 strcpy(imagepath,zc_get_config("zquest",image_path_name,default_path));
23583 8 strcpy(tmusicpath,zc_get_config("zquest",tmusic_path_name,default_path));
23584 8 chop_path(datapath);
23585 8 chop_path(midipath);
23586 8 chop_path(imagepath);
23587 8 chop_path(tmusicpath);
23588
23589 8 DisableLPalShortcuts = zc_get_config("zquest","dis_lpal_shortcut",1);
23590 8 DisableCompileConsole = zc_get_config("zquest","internal_compile_console",0);
23591 8 MouseScroll = zc_get_config("zquest","mouse_scroll",0);
23592 8 MMapCursorStyle = zc_get_config("zquest","cursorblink_style",1);
23593 8 LayerDitherBG = zc_get_config("zquest", "layer_dither_bg", -1);
23594 8 LayerDitherSz = zc_get_config("zquest", "layer_dither_sz", 3);
23595 8 InvalidBG = zc_get_config("zquest", "invalid_bg", 0);
23596 8 TileProtection = zc_get_config("zquest","tile_protection",1);
23597 8 ComboProtection = zc_get_config("zquest","combo_protection",TileProtection);
23598 8 ShowGrid = zc_get_config("zquest","show_grid",0);
23599 8 ShowCurScreenOutline = zc_get_config("zquest","show_current_screen_outline",1);
23600 8 ShowScreenGrid = zc_get_config("zquest","show_screen_grid",0);
23601 8 ShowRegionGrid = zc_get_config("zquest","show_region_grid",1);
23602 8 GridColor = zc_get_config("zquest","grid_color",15);
23603 8 CmbCursorCol = zc_get_config("zquest","combo_cursor_color",15);
23604 8 TilePgCursorCol = zc_get_config("zquest","tpage_cursor_color",15);
23605 8 CmbPgCursorCol = zc_get_config("zquest","cpage_cursor_color",15);
23606 8 TTipHLCol = zc_get_config("zquest","ttip_hl_color",13);
23607 8 CheckerCol1 = zc_get_config("zquest","checker_color_1",7);
23608 8 CheckerCol2 = zc_get_config("zquest","checker_color_2",8);
23609 8 SnapshotFormat = zc_get_config("zquest","snapshot_format",3);
23610 8 SnapshotScale = zc_get_config("zquest","snapshot_scale",2);
23611 8 SavePaths = zc_get_config("zquest","save_paths",1);
23612 8 CycleOn = zc_get_config("zquest","cycle_on",1);
23613 8 ShowFPS = zc_get_config("zquest","showfps",0)!=0;
23614 8 SaveDragResize = zc_get_config("zquest","save_drag_resize",0)!=0;
23615 8 DragAspect = zc_get_config("zquest","drag_aspect",0)!=0;
23616 8 SaveWinPos = zc_get_config("zquest","save_window_position",0)!=0;
23617 8 ComboBrush = zc_get_config("zquest","combo_brush",0);
23618 8 FloatBrush = zc_get_config("zquest","float_brush",0);
23619 8 AutoBrush = zc_get_config("zquest","autobrush",1);
23620 8 LinkedScroll = zc_get_config("zquest","linked_comboscroll",0);
23621 8 allowHideMouse = zc_get_config("ZQ_GUI","allowHideMouse",0);
23622 8 ShowFavoriteComboModes = zc_get_config("ZQ_GUI","show_fav_combo_modes",1);
23623 8 NoHighlightLayer0 = zc_get_config("zquest","no_highlight_layer0",0);
23624 8 RulesetDialog = zc_get_config("zquest","rulesetdialog",1);
23625 8 EnableTooltips = zc_get_config("zquest","enable_tooltips",1);
23626 8 TooltipsHighlight = zc_get_config("zquest","ttip_highlight",1);
23627 8 tooltip_maxtimer = vbound(zc_get_config("zquest","ttip_timer",30),0,60*60);
23628 8 ShowFFScripts = zc_get_config("zquest","showffscripts",1);
23629 8 ShowSquares = zc_get_config("zquest","showsquares",1);
23630 8 ShowFFCs = zc_get_config("zquest","showffcs",0);
23631 8 ShowInfo = zc_get_config("zquest","showinfo",1);
23632 8 skipLayerWarning = zc_get_config("zquest","skip_layer_warning",0);
23633 8 numericalFlags = zc_get_config("zquest","numerical_flags",0);
23634 8 ViewLayer2BG = zc_get_config("zquest","layer2_bg",0);
23635 8 ViewLayer3BG = zc_get_config("zquest","layer3_bg",0);
23636 8 ActiveLayerHighlight = zc_get_config("zquest","hl_active_lyr",0);
23637 8 DragCenterOfSquares = zc_get_config("zquest","drag_squares_from_center",0);
23638
23639 8 OpenLastQuest = zc_get_config("zquest","open_last_quest",0);
23640 8 ShowMisalignments = zc_get_config("zquest","show_misalignments",0);
23641 8 AnimationOn = zc_get_config("zquest","animation_on",1);
23642 8 AutoBackupRetention = zc_get_config("zquest","auto_backup_retention",2);
23643 8 AutoSaveInterval = zc_get_config("zquest","auto_save_interval",6);
23644 8 AutoSaveRetention = zc_get_config("zquest","auto_save_retention",2);
23645 8 UncompressedAutoSaves = zc_get_config("zquest","uncompressed_auto_saves",1);
23646 8 OverwriteProtection = zc_get_config("zquest","overwrite_prevention",0)!=0;
23647 8 ImportMapBias = zc_get_config("zquest","import_map_bias",0);
23648
23649 8 KeyboardRepeatDelay = zc_get_config("zquest","keyboard_repeat_delay",300);
23650 8 KeyboardRepeatRate = zc_get_config("zquest","keyboard_repeat_rate",80);
23651
23652 // Frameskip = zc_get_config("zquest","frameskip",0); //todo: this is not actually supported yet.
23653 8 RequestedFPS = zc_get_config("zquest","fps",60);
23654
23655 // Autofill for Combo Page, Tile Page
23656 8 PreFillTileEditorPage = zc_get_config("zquest","PreFillTileEditorPage",0);
23657 8 PreFillComboEditorPage = zc_get_config("zquest","PreFillComboEditorPage",0);
23658
23659 8 pixeldb = zc_get_config("ZQ_GUI","bottom_8_pixels",0);
23660 8 infobg = zc_get_config("ZQ_GUI","info_text_bg",0);
23661
23662 8 large_merged_combopane = zc_get_config("ZQ_GUI","merge_cpane_large",0);
23663 8 compact_merged_combopane = zc_get_config("ZQ_GUI","merge_cpane_compact",1);
23664
23665 8 compact_square_panels = zc_get_config("ZQ_GUI","square_panels_compact",0);
23666
23667 8 large_zoomed_fav = zc_get_config("ZQ_GUI","zoom_fav_large",0);
23668 8 compact_zoomed_fav = zc_get_config("ZQ_GUI","zoom_fav_compact",1);
23669 8 large_zoomed_cmd = zc_get_config("ZQ_GUI","zoom_cmd_large",1);
23670 8 compact_zoomed_cmd = zc_get_config("ZQ_GUI","zoom_cmd_compact",1);
23671
23672
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(zc_get_config("gui","disable_window_resizing",0))
23673 all_set_resize_flag(false);
23674
23675 8 load_hotkeys();
23676
23677 #ifdef _WIN32
23678 zqUseWin32Proc = zc_get_config("zquest","zq_win_proc_fix",0);
23679
23680 #endif
23681
23682
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (!render_timer_start())
23683 {
23684 Z_error_fatal("couldn't allocate timer");
23685 }
23686
23687 8 byte layermask = zc_get_config("zquest","layer_mask",0x7F);
23688 8 int32_t usefullscreen = zc_get_config("zquest","fullscreen",0);
23689 8 tempmode = (usefullscreen == 0 ? GFX_AUTODETECT_WINDOWED : GFX_AUTODETECT_FULLSCREEN);
23690
23691
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 8 times.
64 for(int32_t x=0; x<7; x++)
23692 {
23693 56 LayerMaskInt[x]=get_bit(&layermask,x);
23694 56 }
23695
23696 8 DuplicateAction[0] = zc_get_config("zquest","normal_duplicate_action",2);
23697 8 DuplicateAction[1] = zc_get_config("zquest","horizontal_duplicate_action",0);
23698 8 DuplicateAction[2] = zc_get_config("zquest","vertical_duplicate_action",0);
23699 8 DuplicateAction[3] = zc_get_config("zquest","both_duplicate_action",0);
23700 8 LeechUpdate = zc_get_config("zquest","leech_update",500);
23701 8 LeechUpdateTiles = zc_get_config("zquest","leech_update_tiles",1);
23702 8 OnlyCheckNewTilesForDuplicates = zc_get_config("zquest","only_check_new_tiles_for_duplicates",0);
23703 //gui_colorset = zc_get_config("zquest","gui_colorset",0);
23704
23705 8 strcpy(last_timed_save,zc_get_config("zquest","last_timed_save",""));
23706
23707 8 midi_volume = zc_get_config("zquest", "midi", 255);
23708
23709 8 abc_patternmatch = zc_get_config("zquest", "lister_pattern_matching", 1);
23710 8 NoScreenPreview = zc_get_config("zquest", "no_preview", 0);
23711
23712 8 monochrome_console = zc_get_config("CONSOLE","monochrome_debuggers",0)?1:0;
23713
23714 8 try_recovering_missing_scripts = 0;//zc_get_config("Compiler", "try_recovering_missing_scripts",0);
23715 //We need to remove all of the zeldadx refs to the config file for zquest.
23716
23717 8 set_keyboard_rate(KeyboardRepeatDelay,KeyboardRepeatRate);
23718
23719 8 is_compact = zc_get_config("ZQ_GUI","compact_mode",1);
23720 8 mapscreenbmp = nullptr;
23721 8 brushbmp = nullptr;
23722 8 brushscreen = nullptr;
23723 8 screen2 = nullptr;
23724 8 tmp_scr = nullptr;
23725 8 menu1 = nullptr;
23726 8 menu3 = nullptr;
23727
23728
2/2
✓ Branch 0 taken 10080 times.
✓ Branch 1 taken 8 times.
10088 for(int32_t i=0; i<MAXFAVORITECOMBOS; ++i)
23729 {
23730 10080 favorite_combos[i]=-1;
23731 10080 pool_combos[i].clear();
23732 10080 }
23733 8 FavoriteComboPage = 0;
23734 8 pool_dirty = true;
23735
23736
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(used_switch(argc,argv,"-d"))
23737 {
23738 set_debug(!strcmp(zquestpwd,zc_get_config("zquest","debug_this","")));
23739 }
23740
23741 8 zcmusic_init();
23742 8 zcmixer = zcmixer_create();
23743 1078 install_int_ex([](){ zcmusic_poll(); }, MSEC_TO_TIMER(25));
23744
23745 8 set_color_depth(8);
23746
23747 8 set_close_button_callback((void (*)()) hit_close_button);
23748
23749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(used_switch(argc,argv,"-fullscreen"))
23750 {
23751 tempmode = GFX_AUTODETECT_FULLSCREEN;
23752 }
23753
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 else if(used_switch(argc,argv,"-windowed"))
23754 {
23755 tempmode=GFX_AUTODETECT_WINDOWED;
23756 }
23757
23758 8 zq_screen_w = LARGE_W;
23759 8 zq_screen_h = LARGE_H;
23760 8 window_width = zc_get_config("zquest","window_width",-1);
23761 8 window_height = zc_get_config("zquest","window_height",-1);
23762 8 auto [w, h] = zc_get_default_display_size(LARGE_W, LARGE_H, window_width, window_height);
23763
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 int32_t videofail = is_headless() ? 0 : (set_gfx_mode(tempmode,w,h,zq_screen_w,zq_screen_h));
23764
23765 //extra block here is intentional
23766
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(videofail!=0)
23767 {
23768 quit_game();
23769 allegro_exit();
23770 }
23771
23772 8 zalleg_create_window();
23773 8 Z_message("gfx mode set at -%d %dbpp %d x %d \n",
23774 8 tempmode, get_color_depth(), zq_screen_w, zq_screen_h);
23775
23776 8 set_window_title("ZC Editor");
23777
23778 8 load_size_poses();
23779
23780
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (!is_headless())
23781 {
23782 // Just in case.
23783 while (!all_get_display()) {
23784 al_rest(1);
23785 }
23786
23787 al_resize_display(all_get_display(), w, h);
23788 }
23789
23790
23791 #ifndef __EMSCRIPTEN__
23792
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (!all_get_fullscreen_flag() && !is_headless()) {
23793 al_resize_display(all_get_display(), w, h);
23794
23795 int window_w = al_get_display_width(all_get_display());
23796 int window_h = al_get_display_height(all_get_display());
23797
23798 int new_x = zc_get_config("zquest","window_x",0);
23799 int new_y = zc_get_config("zquest","window_y",0);
23800 if(zc_get_config("zquest","save_window_position",0) && (new_x || new_y))
23801 {
23802 //load saved position
23803 //already stored in new_x/new_y
23804 }
23805 else
23806 {
23807 //Get default position
23808 ALLEGRO_MONITOR_INFO info;
23809 al_get_monitor_info(0, &info);
23810
23811 int mw = (info.x2 - info.x1);
23812 int mh = (info.y2 - info.y1);
23813 new_x = mw / 2 - window_w / 2;
23814 new_y = mh / 2 - window_h / 2;
23815 //Don't spawn the window too far down (taskbar?)
23816 if(new_y + window_h > mh - 72)
23817 new_y = mh-72-window_h;
23818 }
23819 #ifdef ALLEGRO_MACOSX
23820 if (zc_get_config("zquest","save_window_position",0))
23821 al_set_window_position(all_get_display(), new_x, new_y);
23822 #else
23823 al_set_window_position(all_get_display(), new_x, new_y);
23824 #endif
23825 }
23826 #endif
23827
23828 8 position_mouse(zq_screen_w/2,zq_screen_h/2);
23829
23830 8 dmapbmp_small = create_bitmap_ex(8,65,33);
23831 8 dmapbmp_large = create_bitmap_ex(8,177,81);
23832
23833
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!screen2 || !tmp_scr || !menu1 || !menu3 || !dmapbmp_large || !dmapbmp_large || !brushbmp || !brushscreen)// || !brushshadowbmp )
23834 {
23835 Z_error_fatal("Failed to create system bitmaps!\n");
23836 return 1;
23837 }
23838
23839 8 int quick_assign_arg = used_switch(argc, argv, "-quick-assign");
23840
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6 times.
8 if (quick_assign_arg > 0)
23841 {
23842 6 is_zq_replay_test = true;
23843 6 set_headless_mode();
23844
23845 6 int load_ret = load_quest(argv[quick_assign_arg + 1], false);
23846 6 bool success = load_ret == qe_OK;
23847
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (!success)
23848 {
23849 printf("Failed to load quest: %d\n", load_ret);
23850 zq_exit(1);
23851 }
23852
23853 6 success = do_compile_and_slots(1, false);
23854
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (!success)
23855 {
23856 printf("Failed to compile\n");
23857 zq_exit(1);
23858 }
23859
23860 6 success = save_quest(argv[quick_assign_arg + 1], false) == 0;
23861
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (!success)
23862 {
23863 printf("Failed to save quest\n");
23864 zq_exit(1);
23865 }
23866
23867 6 zq_exit(0);
23868 6 }
23869
23870 8 int smart_assign_arg = used_switch(argc, argv, "-smart-assign");
23871
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (smart_assign_arg > 0)
23872 {
23873 is_zq_replay_test = true;
23874 set_headless_mode();
23875
23876 int load_ret = load_quest(argv[smart_assign_arg + 1], false);
23877 bool success = load_ret == qe_OK;
23878 if (!success)
23879 {
23880 printf("Failed to load quest: %d\n", load_ret);
23881 zq_exit(1);
23882 }
23883
23884 success = do_compile_and_slots(2, false);
23885 if (!success)
23886 {
23887 printf("Failed to compile\n");
23888 zq_exit(1);
23889 }
23890
23891 success = save_quest(argv[smart_assign_arg + 1], false) == 0;
23892 if (!success)
23893 {
23894 printf("Failed to save quest\n");
23895 zq_exit(1);
23896 }
23897
23898 zq_exit(0);
23899 }
23900
23901 8 int export_strings_arg = used_switch(argc, argv, "-export-strings");
23902
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if (export_strings_arg > 0)
23903 {
23904
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (export_strings_arg + 3 > argc)
23905 {
23906 printf("%d\n", argc);
23907 printf("expected -export-strings input.qst output.tsv\n");
23908 zq_exit(1);
23909 }
23910
23911 1 is_zq_replay_test = true;
23912 1 set_headless_mode();
23913
23914 1 int load_ret = load_quest(argv[export_strings_arg + 1], false);
23915 1 bool success = load_ret == qe_OK;
23916
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!success)
23917 {
23918 printf("Failed to load quest: %d\n", load_ret);
23919 zq_exit(1);
23920 }
23921
23922 1 success = save_strings_tsv(argv[export_strings_arg + 2]);
23923
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!success)
23924 {
23925 printf("Failed to export strings\n");
23926 zq_exit(1);
23927 }
23928
23929 1 zq_exit(0);
23930 1 }
23931
23932
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (!is_headless())
23933 {
23934 zc_set_palette(asset_pal);
23935 get_palette(RAMpal);
23936 load_colorset(gui_colorset);
23937 zc_set_palette(RAMpal);
23938 clear_to_color(screen,vc(0));
23939 }
23940
23941 8 zScript = string();
23942 8 strcpy(zScriptBytes, "0 Bytes in Buffer");
23943
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8 times.
20 for(int32_t i=0; i<MOUSE_BMP_MAX; i++)
23944 {
23945
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 for(int32_t j=0; j<4; j++)
23946 {
23947 48 mouse_bmp[i][j] = NULL;
23948 48 mouse_bmp_1x[i][j] = NULL;
23949 48 }
23950 12 }
23951 8 load_mice();
23952 8 gui_mouse_focus=0;
23953 8 MouseSprite::set(ZQM_NORMAL);
23954 8 render_zq(); // Ensure the rendering bitmaps are setup.
23955
23956 #ifdef __EMSCRIPTEN__
23957 em_mark_ready_status();
23958 #endif
23959
23960 8 load_icons();
23961
23962 8 bool load_last_timed_save=false;
23963
23964 8 load_recent_quests();
23965 8 refresh_recent_menu();
23966 //clearConsole();
23967
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if((last_timed_save[0]!=0)&&(exists(last_timed_save)))
23968 {
23969 if(jwin_alert("ZQuest","It appears that ZQuest crashed last time.","Would you like to load the last timed save?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
23970 {
23971 int32_t ret = load_quest(last_timed_save);
23972
23973 if(ret == qe_OK)
23974 {
23975 strcpy(filepath,last_timed_save);
23976 load_last_timed_save=true;
23977 saved=false;
23978 }
23979 else
23980 {
23981 jwin_alert("Error","Unable to reload the last timed save.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
23982 }
23983 }
23984 }
23985
23986
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(!load_last_timed_save)
23987 {
23988 1 strcpy(filepath,zc_get_config("zquest",last_quest_name,""));
23989
23990
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(argc>1 && argv[1][0]!='-')
23991 {
23992 int32_t ret = load_quest(argv[1]);
23993
23994 if(ret == qe_OK)
23995 {
23996 first_save=true;
23997 strcpy(filepath,argv[1]);
23998 refresh(rALL);
23999 }
24000 }
24001
2/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 else if(OpenLastQuest&&filepath[0]&&exists(filepath)&&!used_switch(argc,argv,"-new"))
24002 {
24003 int32_t ret = load_quest(filepath);
24004
24005 if(ret == qe_OK)
24006 {
24007 first_save=true;
24008 refresh(rALL);
24009 }
24010 else
24011 {
24012 filepath[0]=temppath[0]=0;
24013 first_save=false;
24014 }
24015 }
24016 else
24017 {
24018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (onNew() == D_CLOSE)
24019 {
24020 1 Z_message("User canceled creating new quest, closing.\n");
24021 1 exit(0);
24022 }
24023
24024 //otherwise the blank quest gets the name of the last loaded quest... not good! -DD
24025 filepath[0]=temppath[0]=0;
24026 first_save=false;
24027 }
24028 }
24029
24030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(used_switch(argc,argv,"-q"))
24031 {
24032 Z_message("-q switch used, quitting program.\n");
24033 zq_exit(0);
24034 }
24035
24036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 for(int32_t x=0; x<MAXITEMS; x++)
24037 {
24038 lens_hint_item[x][0]=0;
24039 lens_hint_item[x][1]=0;
24040 }
24041
24042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 for(int32_t x=0; x<MAXWPNS; x++)
24043 {
24044 lens_hint_weapon[x][0]=0;
24045 lens_hint_weapon[x][1]=0;
24046 }
24047
24048 7 load_selections();
24049 7 load_arrows();
24050 7 clear_to_color(menu1,vc(0));
24051 7 DIALOG_PLAYER *player2=init_dialog(dialogs,-1);
24052
24053 7 get_palette(RAMpal);
24054
24055 7 rgb_map = &zq_rgb_table;
24056
24057 #ifdef __EMSCRIPTEN__
24058 {
24059 int qs_map = EM_ASM_INT({
24060 return new URL(location.href).searchParams.get('map') ?? -1;
24061 });
24062 int qs_screen = EM_ASM_INT({
24063 return new URL(location.href).searchParams.get('screen') ?? -1;
24064 });
24065 if (qs_map != -1 && qs_screen != -1) {
24066 Map.setCurrMap(qs_map);
24067 Map.setCurrScr(qs_screen);
24068 }
24069 }
24070 #endif
24071
24072 // setup_combo_animations();
24073 7 pause_refresh = false;
24074 7 refresh_pal();
24075 7 refresh(rALL);
24076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 for(int q = 0; q < brush_width_menu.size(); ++q)
24077 brush_width_menu.at(q)->select(q==0);
24078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 for(int q = 0; q < brush_height_menu.size(); ++q)
24079 brush_height_menu.at(q)->select(q==0);
24080 7 set_filltype(1);
24081
24082 7 rebuild_trans_table();
24083
24084
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if (!is_headless())
24085 {
24086 set_display_switch_mode(SWITCH_BACKGROUND);
24087 set_display_switch_callback(SWITCH_OUT, switch_out);
24088 set_display_switch_callback(SWITCH_IN, switch_in);
24089 }
24090
24091
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!update_dialog(player2))
24092 exiting_program = true;
24093 //clear_keybuf();
24094 7 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
24095 7 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
24096
24097 7 fix_drawing_mode_menu();
24098
24099
24100 #ifdef _WIN32
24101
24102 if(zqUseWin32Proc != FALSE)
24103 {
24104 al_trace("Config file warning: \"zq_win_proc_fix\" enabled switch found. This can cause crashes on some computers.\n");
24105 win32data.zqSetDefaultThreadPriority(0);
24106 win32data.zqSetCustomCallbackProc(al_get_win_window_handle(all_get_display()));
24107 }
24108
24109 #endif
24110
24111 7 time(&auto_save_time_start);
24112
24113 7 FFCore.init();
24114 7 ZQincludePaths = FFCore.includePaths;
24115
24116 7 Map.setCopyFFC(-1); //Do not have an initial ffc on the clipboard.
24117 7 brush_menu.select_uid(MENUID_BRUSH_AUTOBRUSH, AutoBrush);
24118 7 brush_menu.disable_uid(MENUID_BRUSH_WIDTH, AutoBrush);
24119 7 brush_menu.disable_uid(MENUID_BRUSH_HEIGHT, AutoBrush);
24120 7 brush_menu.select_uid(MENUID_BRUSH_COMBOBRUSH, ComboBrush);
24121 7 brush_menu.select_uid(MENUID_BRUSH_FLOATBRUSH, FloatBrush);
24122
24123 7 call_foo_dlg();
24124
24125 7 application_has_loaded = true;
24126
24127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 while(!exiting_program)
24128 {
24129 handle_sentry_tags();
24130
24131 #ifdef _WIN32
24132 if(zqUseWin32Proc != FALSE)
24133 win32data.Update(Frameskip); //experimental win32 fixes
24134 #endif
24135 check_autosave();
24136 ++alignment_arrow_timer;
24137
24138 if(alignment_arrow_timer>63)
24139 {
24140 alignment_arrow_timer=0;
24141 }
24142 ++frame;
24143
24144 file_menu.disable_uid(MENUID_FILE_SAVE, saved||disable_saving||OverwriteProtection);
24145 file_menu.disable_uid(MENUID_FILE_REVERT, saved||disable_saving||OverwriteProtection);
24146 file_menu.disable_uid(MENUID_FILE_SAVEAS, disable_saving);
24147
24148 fixtools_menu.disable_uid(MENUID_FIXTOOL_OLDSTRING,
24149 !(get_qr(qr_OLD_STRING_EDITOR_MARGINS)
24150 ||get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)));
24151
24152 edit_menu.disable_uid(MENUID_EDIT_UNDO, !Map.CanUndo());
24153 edit_menu.disable_uid(MENUID_EDIT_REDO, !Map.CanRedo());
24154
24155 bool canpaste = Map.CanPaste();
24156 edit_menu.disable_uid(MENUID_EDIT_PASTE, !canpaste);
24157 edit_menu.disable_uid(MENUID_EDIT_PASTEALL, !canpaste);
24158 edit_menu.disable_uid(MENUID_EDIT_ADVPASTE, !canpaste);
24159 edit_menu.disable_uid(MENUID_EDIT_SPECPASTE, !canpaste);
24160 rc_menu_screen.disable_uid(MENUID_RCSCREEN_PASTE, !canpaste);
24161 rc_menu_screen.disable_uid(MENUID_RCSCREEN_ADVPASTE, !canpaste);
24162 rc_menu_screen.disable_uid(MENUID_RCSCREEN_SPECPASTE, !canpaste);
24163 for(MenuItem& mit : paste_menu.inner())
24164 mit.disable(!canpaste);
24165 for(MenuItem& mit : paste_item_menu.inner())
24166 mit.disable(!canpaste);
24167
24168 edit_menu.disable_uid(MENUID_EDIT_COPY, !(Map.CurrScr()->valid&mVALID));
24169 edit_menu.disable_uid(MENUID_EDIT_DELETE, !(Map.CurrScr()->valid&mVALID));
24170
24171 // Are some things selected?
24172 view_menu.select_uid(MENUID_VIEW_WALKABILITY, Flags&cWALK);
24173 view_menu.select_uid(MENUID_VIEW_FLAGS, Flags&cFLAGS);
24174 view_menu.select_uid(MENUID_VIEW_CSET, Flags&cCSET);
24175 view_menu.select_uid(MENUID_VIEW_TYPES, Flags&cCTYPE);
24176 view_menu.select_uid(MENUID_VIEW_INFO, ShowInfo);
24177 view_menu.select_uid(MENUID_VIEW_SQUARES, ShowSquares);
24178 view_menu.select_uid(MENUID_VIEW_FFCS, ShowFFCs);
24179 view_menu.select_uid(MENUID_VIEW_SCRIPTNAMES, ShowFFScripts);
24180 view_menu.select_uid(MENUID_VIEW_GRID, ShowGrid);
24181 view_menu.select_uid(MENUID_VIEW_SCREENGRID, ShowScreenGrid);
24182 view_menu.select_uid(MENUID_VIEW_REGIONGRID, ShowRegionGrid);
24183 view_menu.select_uid(MENUID_VIEW_CURSCROUTLINE, ShowCurScreenOutline);
24184 view_menu.select_uid(MENUID_VIEW_DARKNESS, get_qr(qr_NEW_DARKROOM) && (Flags&cNEWDARK));
24185 view_menu.select_uid(MENUID_VIEW_L2BG, ViewLayer2BG);
24186 view_menu.select_uid(MENUID_VIEW_L3BG, ViewLayer3BG);
24187 view_menu.select_uid(MENUID_VIEW_LAYERHIGHLIGHT, ActiveLayerHighlight);
24188
24189 maps_menu.disable_uid(MENUID_MAPS_NEXT, !map_count || Map.getCurrMap() >= map_count);
24190 maps_menu.disable_uid(MENUID_MAPS_PREV, Map.getCurrMap()<=0);
24191
24192 etc_menu.disable_uid(MENUID_ETC_VIDMODE, isFullScreen()==1);
24193 etc_menu.select_uid(MENUID_ETC_FULLSCREEN, isFullScreen()==1);
24194
24195 if(!update_dialog(player2))
24196 exiting_program = true;
24197
24198 //clear_keybuf();
24199 handle_close_btn_quit();
24200 }
24201
24202 7 zq_exit(0);
24203 7 return 0;
24204 }
24205 END_OF_MAIN()
24206
24207 11 void zq_exit(int code)
24208 {
24209 11 set_is_exiting();
24210 11 parser_console.kill();
24211 11 killConsole();
24212
24213 11 quit_game();
24214 11 allegro_exit();
24215 11 exit(code);
24216 }
24217
24218 56 void init_bitmap(BITMAP** bmp, int32_t w, int32_t h)
24219 {
24220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(*bmp)
24221 destroy_bitmap(*bmp);
24222 56 *bmp = create_bitmap_ex(8,w,h);
24223 56 clear_bitmap(*bmp);
24224 56 }
24225 8 void load_size_poses()
24226 {
24227 8 ttip_uninstall_all();
24228
24229 8 FONT* favcmdfont = get_custom_font(CFONT_FAVCMD);
24230 8 FONT* guifont = get_custom_font(CFONT_GUI);
24231
24232 8 d_nbmenu_proc(MSG_START, &dialogs[0], 0);
24233
24234 8 commands_list.xscale = command_buttonwidth;
24235 8 commands_list.yscale = 10+text_height(favcmdfont);
24236
24237 8 auto drawmode_wid = 64;
24238
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 8 times.
56 for(auto q = 0; q < dm_max; ++q)
24239 {
24240 48 auto wid = text_length(guifont, dm_names[q]);
24241
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(wid > drawmode_wid)
24242 drawmode_wid = wid;
24243 48 }
24244
24245 //Main GUI objects
24246
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(is_compact)
24247 {
24248 8 num_combo_cols = 2;
24249 8 combo_col_scale = 16;
24250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(compact_merged_combopane)
24251 {
24252 8 num_combo_cols = 1;
24253 8 combo_col_scale = 32;
24254 8 }
24255
24256 8 mapscreen_x=0;
24257 8 mapscreen_y=dialogs[0].h;
24258 8 mapscreen_screenunit_scale=3;
24259 8 mapscreen_single_scale = (double)mapscreen_screenunit_scale / Map.getViewSize();
24260 8 showedges=0;
24261 8 showallpanels=0;
24262
24263 8 blackout_color=8;
24264
24265 8 auto mapscr_wid = (((showedges?2:0)+16)*16*mapscreen_screenunit_scale);
24266 8 combolist_window.w=zq_screen_w-mapscr_wid;
24267 8 combolist_window.x=zq_screen_w-combolist_window.w;
24268
24269 8 favorites_window.x=combolist_window.x;
24270 8 favorites_window.w=combolist_window.w;
24271 8 favorites_window.h=136;
24272 8 favorites_window.y=zq_screen_h-favorites_window.h;
24273
24274 8 combolist_window.y=0;
24275 8 combolist_window.h=favorites_window.y-combolist_window.y;
24276
24277 8 combo_preview.x=zq_screen_w-32-8;
24278 8 combo_preview.y=combolist_window.y+6;
24279 8 combo_preview.w=32;
24280 8 combo_preview.h=32;
24281 8 combo_preview2.clear();
24282
24283 8 auto col_wid = 4*combo_col_scale;
24284 8 auto cols_wid = col_wid * num_combo_cols;
24285 8 auto cols_spacing = (combolist_window.w-cols_wid)/(num_combo_cols+1);
24286
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 for(auto q = 0; q < num_combo_cols; ++q)
24287 {
24288 8 combolist[q].x=combolist_window.x+(cols_spacing*(q+1))+(col_wid*q);
24289 8 combolist[q].y=combolist_window.y+54;
24290 8 combolist[q].w=4;
24291 8 combolist[q].h=compact_merged_combopane ? 15 : 30;
24292 8 combolist[q].xscale = combo_col_scale;
24293 8 combolist[q].yscale = combo_col_scale;
24294
24295 8 comboaliaslist[q].x = combolist[q].x;
24296 8 comboaliaslist[q].y = combolist[q].y;
24297 8 comboaliaslist[q].w = 4;
24298 8 comboaliaslist[q].h = compact_merged_combopane ? 13 : 26;
24299 8 comboaliaslist[q].xscale = combo_col_scale;
24300 8 comboaliaslist[q].yscale = combo_col_scale;
24301
24302 8 combolistscrollers[q].w=2;
24303 8 combolistscrollers[q].h=1;
24304 8 combolistscrollers[q].xscale=11;
24305 8 combolistscrollers[q].yscale=11;
24306 8 combolistscrollers[q].x=combolist[q].x+(combolist[q].w*combolist[q].xscale/2)-11;
24307 8 combolistscrollers[q].y=combolist[q].y-combolistscrollers[q].th()-3;
24308 8 }
24309
24310 8 comboalias_preview.x=zq_screen_w-((combolist_window.w+64)/2);
24311 8 comboalias_preview.h=64;
24312 8 comboalias_preview.y=favorites_window.y-comboalias_preview.h-8;
24313 8 comboalias_preview.w=64;
24314
24315 8 combo_merge_btn.w = 20;
24316 8 combo_merge_btn.h = 20;
24317 8 combo_merge_btn.x = zq_screen_w-(combolist_window.w+combo_merge_btn.w)/2;
24318 8 combo_merge_btn.y = combolist[0].y-combo_merge_btn.h;
24319
24320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(num_combo_cols == 1)
24321 {
24322 8 combolistscrollers[0].x += 34;
24323 8 }
24324 8 drawmode_btn.x = combolist_window.x-drawmode_wid;
24325 8 drawmode_btn.y = 0;
24326 8 drawmode_btn.w = drawmode_wid;
24327 8 drawmode_btn.h = mapscreen_y;
24328
24329 8 compactbtn.w = text_length(guifont,"> Compact")+10;
24330 8 compactbtn.x = drawmode_btn.x-compactbtn.w;
24331 8 compactbtn.y = drawmode_btn.y;
24332 8 compactbtn.h = drawmode_btn.h;
24333
24334 8 zoominbtn.w = text_length(guifont,"+")+10;
24335 8 zoominbtn.x = compactbtn.x-zoominbtn.w;
24336 8 zoominbtn.y = compactbtn.y;
24337 8 zoominbtn.h = compactbtn.h;
24338
24339 8 zoomoutbtn.w = text_length(guifont,"-")+10;
24340 8 zoomoutbtn.x = zoominbtn.x-zoomoutbtn.w;
24341 8 zoomoutbtn.y = compactbtn.y;
24342 8 zoomoutbtn.h = compactbtn.h;
24343
24344
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 8 times.
80 for(int32_t i=0; i<=8; i++)
24345 {
24346 72 map_page_bar[i].w = 48;
24347 72 map_page_bar[i].x = mapscreen_x+(i*48);
24348 72 map_page_bar[i].y = mapscreen_y+(11*16*mapscreen_screenunit_scale);
24349 72 map_page_bar[i].h = text_height(guifont)+12;
24350 72 }
24351
24352 8 minimap.w=7+48*3;
24353 8 minimap.h=16+27*3;
24354
24355 8 layer_panel.x=map_page_bar[6].x;
24356 8 layer_panel.y=map_page_bar[0].y;
24357 8 layer_panel.w=combolist_window.x - layer_panel.x;
24358 8 layer_panel.h=map_page_bar[0].h;
24359 8 layerpanel_buttonwidth = 51;
24360 8 layerpanel_buttonheight = layer_panel.h;
24361 8 layerpanel_checkbox_hei = layerpanel_buttonheight-4;
24362 8 layerpanel_checkbox_wid = 15;
24363
24364 8 minimap.x=3;
24365 8 minimap.y=layer_panel.y+layer_panel.h+4;
24366
24367 8 real_minimap.x = minimap.x+3;
24368 8 real_minimap.y = minimap.y+5;
24369 8 real_minimap.w = 16;
24370 8 real_minimap.h = 9;
24371 8 real_minimap.xscale = 9;
24372 8 real_minimap.yscale = 9;
24373 8 real_minimap.fw = real_minimap.xscale*8;
24374 8 real_minimap.fh = real_minimap.yscale*8;
24375
24376 8 int upscale_mm = 3;
24377 8 int xwid = real_minimap.tw()*(upscale_mm-1);
24378 8 int xhei = real_minimap.th()*(upscale_mm-1);
24379 8 minimap_zoomed.set(minimap.x, minimap.y-xhei, minimap.w+xwid, minimap.h+xhei+4);
24380 8 real_minimap_zoomed.set(minimap_zoomed.x+3, minimap_zoomed.y+5, real_minimap.w, real_minimap.h, real_minimap.xscale*upscale_mm, real_minimap.yscale*upscale_mm);
24381 8 real_minimap_zoomed.fw = real_minimap_zoomed.xscale*8;
24382 8 real_minimap_zoomed.fh = real_minimap_zoomed.yscale*8;
24383
24384 8 screrrorpos.x = combolist_window.x - 3;
24385 8 screrrorpos.y = layer_panel.y - 16;
24386
24387 8 mouse_scroll_h=10;
24388
24389 8 favorites_list.x=favorites_window.x+8;
24390 8 favorites_list.y=favorites_window.y+16;
24391 8 favorites_list.xscale = 16;
24392 8 favorites_list.yscale = 16;
24393 8 favorites_list.w=(favorites_window.w-16)/favorites_list.xscale;
24394 8 favorites_list.h=(favorites_window.h-24)/favorites_list.yscale;
24395
24396 8 commands_list.w=4;
24397
24398 8 int bh = commands_list.yscale;
24399 8 int bw = 26;
24400 8 commands_window.w=commands_list.w*commands_list.xscale+10+bw;
24401 8 commands_window.x=combolist_window.x-commands_window.w;
24402 8 commands_window.y=layer_panel.y+layer_panel.h;
24403 8 commands_window.h=zq_screen_h-commands_window.y;
24404 8 int bx = commands_window.x+2;
24405
24406 8 commands_list.y=commands_window.y+4;
24407 8 commands_list.h=(zq_screen_h - commands_list.y) / commands_list.yscale;
24408 8 commands_list.x=bx+bw;
24409
24410 8 commands_zoombtn.w = bw;
24411 8 commands_zoombtn.h = bh;
24412 8 commands_zoombtn.x = bx;
24413 8 commands_zoombtn.y = commands_list.y;
24414
24415 8 commands_infobtn.w = bw;
24416 8 commands_infobtn.h = bh;
24417 8 commands_infobtn.x = bx;
24418 8 commands_infobtn.y = commands_zoombtn.y + commands_infobtn.h;
24419
24420 8 commands_x.w = bw;
24421 8 commands_x.h = bh;
24422 8 commands_x.x = bx;
24423 8 commands_x.y = commands_infobtn.y + commands_x.h;
24424
24425 8 commands_txt.clear();
24426
24427 8 main_panel.x = 0;
24428 8 main_panel.y = layer_panel.y+layer_panel.h;
24429 8 main_panel.w = commands_window.x - main_panel.x;
24430 8 main_panel.h = 76+32;
24431 8 preview_panel = main_panel;
24432 8 preview_panel.x = 0;
24433 8 preview_panel.w = commands_window.x - preview_panel.x;
24434
24435 8 preview_text.x = preview_panel.x+3;
24436 8 preview_text.y = preview_panel.y+3;
24437 8 preview_text.w = 2;
24438 8 preview_text.h = 6;
24439 8 preview_text.xscale = 10;
24440 8 preview_text.yscale = text_height(get_zc_font(font_lfont_l));
24441
24442 8 panel_align = 1;
24443 8 int swapbtnw = 32, swapbtnh = 20;
24444 8 int swapbtnx = main_panel.x+main_panel.tw()-swapbtnw;
24445 8 squarepanel_swap_btn.set(swapbtnx, zq_screen_h-swapbtnh, swapbtnw, swapbtnh);
24446
24447 8 int sqx = minimap.x+minimap.tw();
24448 8 squares_panel.set(sqx,main_panel.y,main_panel.tw()-sqx,main_panel.th());
24449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(compact_square_panels)
24450 {
24451 int cmpy = main_panel.y+(main_panel.th()/2);
24452 squarepanel_up_btn.set(swapbtnx, cmpy-swapbtnh, swapbtnw, swapbtnh);
24453 squarepanel_down_btn.set(swapbtnx, cmpy, swapbtnw, swapbtnh);
24454
24455 txtoffs_single.x = 18;
24456 txtoffs_single.y = 36;
24457 txtoffs_double_1.x = 18;
24458 txtoffs_double_1.y = 36;
24459 txtoffs_double_2.x = 18;
24460 txtoffs_double_2.y = 36 + text_height(get_custom_font(CFONT_GUI));
24461
24462 //Clear them all- if they stay cleared, they are invisible.
24463 itemsqr_pos.clear();
24464 stairsqr_pos.clear();
24465 warparrival_pos.clear();
24466 flagsqr_pos.clear();
24467 enemy_prev_pos.clear();
24468 for(int q = 0; q < 4; ++q)
24469 warpret_pos[q].clear();
24470
24471 int sqr_x1 = sqx+12;
24472 int sqr_y1 = main_panel.y+12;
24473 int sqr_xoffs = (16*2)+4 + 12;
24474 switch(compact_active_panel)
24475 {
24476 case 0: //Warp Squares
24477 {
24478 int x = sqr_x1;
24479 for(int q = 0; q < 4; ++q)
24480 {
24481 warpret_pos[q].set(x,sqr_y1,(16*2)+4,(16*2)+4);
24482 x += sqr_xoffs;
24483 }
24484 break;
24485 }
24486 case 1: //Other Squares
24487 {
24488 itemsqr_pos.set(sqr_x1+(sqr_xoffs*0), sqr_y1, (16*2)+4,(16*2)+4);
24489 stairsqr_pos.set(sqr_x1+(sqr_xoffs*1), sqr_y1, (16*2)+4,(16*2)+4);
24490 warparrival_pos.set(sqr_x1+(sqr_xoffs*2), sqr_y1, (16*2)+4,(16*2)+4);
24491 flagsqr_pos.set(sqr_x1+(sqr_xoffs*3), sqr_y1, (16*2)+4,(16*2)+4);
24492 break;
24493 }
24494 case 2: //Enemy Preview
24495 {
24496 enemy_prev_pos.set(sqr_x1, sqr_y1, 5, 2, 32, 32);
24497 break;
24498 }
24499 }
24500 }
24501 else
24502 {
24503 8 squarepanel_up_btn.clear();
24504 8 squarepanel_down_btn.clear();
24505 8 txtoffs_single.x = 10;
24506 8 txtoffs_single.y = 22;
24507 8 txtoffs_double_1.x = 10;
24508 8 txtoffs_double_1.y = 22;
24509 8 txtoffs_double_2.x = 10;
24510 8 txtoffs_double_2.y = 30;
24511
24512
24513 8 int sqr_x1 = sqx+24;
24514 8 int sqr_y1 = main_panel.y+12;
24515 8 int sqr_y2 = sqr_y1+42;
24516 8 int sqr_xdist = 32;
24517 8 itemsqr_pos.set(sqr_x1+(sqr_xdist*0),sqr_y1,20,20);
24518 8 stairsqr_pos.set(sqr_x1+(sqr_xdist*1),sqr_y1,20,20);
24519 8 warparrival_pos.set(sqr_x1+(sqr_xdist*2),sqr_y1,20,20);
24520 8 flagsqr_pos.set(sqr_x1+(sqr_xdist*3),sqr_y1,20,20);
24521
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 8 times.
40 for(auto q = 0; q < 4; ++q)
24522 {
24523 32 warpret_pos[q].set(sqr_x1+(sqr_xdist*q),sqr_y2,20,20);
24524 32 }
24525 8 enemy_prev_pos.set(sqr_x1+(sqr_xdist*4), sqr_y1, 4, 3, 16, 16);
24526 8 enemy_prev_pos.fw = enemy_prev_pos.xscale*2;
24527 8 enemy_prev_pos.fh = enemy_prev_pos.yscale*2;
24528 }
24529
24530 8 auto& last_alias_list = comboaliaslist[num_combo_cols-1];
24531 8 combopool_preview.x=comboaliaslist[0].x;
24532 8 combopool_preview.y=last_alias_list.y+(last_alias_list.h*last_alias_list.yscale)+16;
24533 8 combopool_preview.w=(last_alias_list.x+(last_alias_list.w*last_alias_list.xscale))-comboaliaslist[0].x;
24534 8 combopool_preview.h=zq_screen_h-8-combopool_preview.y;
24535 8 combopool_preview.w -= combopool_preview.w%16;
24536 8 combopool_preview.h -= combopool_preview.h%16;
24537
24538 8 FONT* tfont = get_zc_font(font_lfont_l);
24539 8 combopool_prevbtn.w = text_length(tfont, "Unweighted")+10;
24540 8 combopool_prevbtn.h = 11;
24541 8 combopool_prevbtn.x = combopool_preview.x;
24542 8 combopool_prevbtn.y = combopool_preview.y-combopool_prevbtn.h;
24543
24544 8 mappage_count = 6;
24545
24546 8 txfont = get_zc_font(font_lfont_l);
24547 8 combo_preview_text1.set(combo_preview.x-5,combo_preview.y,1,3,1,text_height(txfont));
24548 8 combo_preview_text2.clear();
24549
24550 8 favorites_x.w = 17;
24551 8 favorites_infobtn.w = 17;
24552 8 favorites_zoombtn.w = 17;
24553 8 favorites_pgleft.w = 17;
24554 8 favorites_pgright.w = 17;
24555 8 }
24556 else
24557 {
24558 num_combo_cols = 4;
24559 combo_col_scale = 16;
24560 if(large_merged_combopane)
24561 {
24562 num_combo_cols = 2;
24563 combo_col_scale = 32;
24564 }
24565
24566 mapscreen_x=0;
24567 mapscreen_y=dialogs[0].h;
24568 mapscreen_screenunit_scale=2;
24569 mapscreen_single_scale = (double)mapscreen_screenunit_scale / Map.getViewSize();
24570 showedges=Map.getViewSize() <= 2 ? 1 : 0;
24571 showallpanels=0;
24572
24573 blackout_color=8;
24574
24575 favorites_window.h=136;
24576 favorites_window.y=zq_screen_h-favorites_window.h;
24577
24578 auto mapscr_wid = (((2)+16)*16*mapscreen_screenunit_scale);
24579 combolist_window.w=zq_screen_w-mapscr_wid;
24580 combolist_window.x=zq_screen_w-combolist_window.w;
24581 combolist_window.y=0;
24582 combolist_window.h=favorites_window.y-combolist_window.y;
24583
24584 favorites_window.x=combolist_window.x;
24585 favorites_window.w=combolist_window.w;
24586
24587 combo_preview.x=(zq_screen_w-(combolist_window.w/2))-40;
24588 combo_preview.y=combolist_window.y+6;
24589 combo_preview.w=32;
24590 combo_preview.h=32;
24591 combo_preview2 = combo_preview;
24592 combo_preview2.x += 48;
24593
24594 auto col_wid = 4*combo_col_scale;
24595 auto cols_wid = col_wid * num_combo_cols;
24596 auto cols_spacing = (combolist_window.w-cols_wid)/(num_combo_cols+1);
24597 for(auto q = 0; q < num_combo_cols; ++q)
24598 {
24599 combolist[q].x=combolist_window.x+(cols_spacing*(q+1))+(col_wid*q);
24600 combolist[q].y=combolist_window.y+60;
24601 combolist[q].w=4;
24602 combolist[q].h=large_merged_combopane ? 15 : 30;
24603 combolist[q].xscale = combo_col_scale;
24604 combolist[q].yscale = combo_col_scale;
24605
24606 comboaliaslist[q].x=combolist[q].x;
24607 comboaliaslist[q].y=combolist[q].y;
24608 comboaliaslist[q].w=4;
24609 comboaliaslist[q].h=large_merged_combopane ? 12 : 25;
24610 comboaliaslist[q].xscale = combo_col_scale;
24611 comboaliaslist[q].yscale = combo_col_scale;
24612
24613 combolistscrollers[q].w=2;
24614 combolistscrollers[q].h=1;
24615 combolistscrollers[q].xscale=11;
24616 combolistscrollers[q].yscale=11;
24617 combolistscrollers[q].x=combolist[q].x+(combolist[q].w*combolist[q].xscale/2)-11;
24618 combolistscrollers[q].y=combolist[q].y-combolistscrollers[q].th()-2;
24619 }
24620
24621 comboalias_preview.x=zq_screen_w-((combolist_window.w+64)/2);
24622 comboalias_preview.h=64;
24623 comboalias_preview.w=64;
24624 comboalias_preview.y=favorites_window.y-comboalias_preview.h-8;
24625
24626 combo_merge_btn.w = 20;
24627 combo_merge_btn.h = 20;
24628 combo_merge_btn.x = zq_screen_w-(combolist_window.w+combo_merge_btn.w)/2;
24629 combo_merge_btn.y = combolist[0].y-combo_merge_btn.h;
24630 squarepanel_swap_btn.clear();
24631 squarepanel_up_btn.clear();
24632 squarepanel_down_btn.clear();
24633
24634 drawmode_btn.x = combolist_window.x-drawmode_wid;
24635 drawmode_btn.y = 0;
24636 drawmode_btn.w = drawmode_wid;
24637 drawmode_btn.h = mapscreen_y;
24638
24639 compactbtn.w = text_length(guifont,"> Compact")+10;
24640 compactbtn.x = drawmode_btn.x-compactbtn.w;
24641 compactbtn.y = drawmode_btn.y;
24642 compactbtn.h = drawmode_btn.h;
24643
24644 zoominbtn.w = text_length(guifont,"+")+10;
24645 zoominbtn.x = compactbtn.x-zoominbtn.w;
24646 zoominbtn.y = compactbtn.y;
24647 zoominbtn.h = compactbtn.h;
24648
24649 zoomoutbtn.w = text_length(guifont,"-")+10;
24650 zoomoutbtn.x = zoominbtn.x-zoomoutbtn.w;
24651 zoomoutbtn.y = compactbtn.y;
24652 zoomoutbtn.h = compactbtn.h;
24653
24654 for(int32_t i=0; i<=8; i++)
24655 {
24656 map_page_bar[i].x = mapscreen_x+(i*16*2*mapscreen_screenunit_scale);
24657 map_page_bar[i].y = mapscreen_y+((13)*16*mapscreen_screenunit_scale);
24658 map_page_bar[i].w = 64;
24659 map_page_bar[i].h = text_height(guifont)+12;
24660 }
24661
24662 minimap.w=7+48*3;
24663 minimap.h=16+27*3;
24664
24665 layer_panel.x=map_page_bar[0].x;
24666 layer_panel.y=map_page_bar[0].y+map_page_bar[0].h;
24667 layer_panel.w=map_page_bar[8].x+map_page_bar[8].w;
24668 layer_panel.h=text_height(guifont)+8;
24669 layerpanel_buttonwidth = 58;
24670 layerpanel_buttonheight = layer_panel.h;
24671 layerpanel_checkbox_hei = layerpanel_buttonheight-4;
24672 layerpanel_checkbox_wid = 14;
24673
24674 commands_list.w=4;
24675 commands_window.w=commands_list.w*commands_list.xscale+16;
24676 commands_window.x=combolist_window.x-commands_window.w;
24677 commands_window.y=layer_panel.y+layer_panel.h;
24678 commands_window.h=zq_screen_h-commands_window.y;
24679
24680 //buttons panel
24681 main_panel.x = 0;
24682 main_panel.y = layer_panel.y+layer_panel.h;
24683 main_panel.w = commands_window.x - main_panel.x;
24684 main_panel.h = zq_screen_h - main_panel.y;
24685 preview_panel = main_panel;
24686
24687 preview_text.x = preview_panel.x+3;
24688 preview_text.y = preview_panel.y+3;
24689 preview_text.w = 1;
24690 preview_text.h = 12;
24691 preview_text.xscale = 10;
24692 preview_text.yscale = text_height(get_zc_font(font_lfont_l));
24693
24694 minimap.x=3;
24695 minimap.y=main_panel.y+4;
24696
24697 real_minimap.x = minimap.x+3;
24698 real_minimap.y = minimap.y+5;
24699 real_minimap.w = 16;
24700 real_minimap.h = 9;
24701 real_minimap.xscale = 9;
24702 real_minimap.yscale = 9;
24703 real_minimap.fw = real_minimap.xscale*8;
24704 real_minimap.fh = real_minimap.yscale*8;
24705
24706 int upscale_mm = 4;
24707 int xwid = real_minimap.tw()*(upscale_mm-1);
24708 int xhei = real_minimap.th()*(upscale_mm-1);
24709 int zh = minimap.h+xhei+4;
24710 minimap_zoomed.set(minimap.x, zq_screen_h-zh, minimap.w+xwid, zh);
24711 real_minimap_zoomed.set(minimap_zoomed.x+3, minimap_zoomed.y+5, real_minimap.w, real_minimap.h, real_minimap.xscale*upscale_mm, real_minimap.yscale*upscale_mm);
24712 real_minimap_zoomed.fw = real_minimap_zoomed.xscale*8;
24713 real_minimap_zoomed.fh = real_minimap_zoomed.yscale*8;
24714
24715 screrrorpos.x = 575;
24716 screrrorpos.y = 388;
24717
24718 mouse_scroll_h=10;
24719
24720 favorites_list.x=favorites_window.x+8;
24721 favorites_list.y=favorites_window.y+16;
24722 favorites_list.xscale = 16;
24723 favorites_list.yscale = 16;
24724 favorites_list.w=(favorites_window.w-16)/favorites_list.xscale;
24725 favorites_list.h=(favorites_window.h-24)/favorites_list.yscale;
24726
24727 int bh = 16;
24728 int by = commands_window.y+4;
24729 commands_list.y=by+bh;
24730 commands_list.h=(zq_screen_h - commands_list.y) / commands_list.yscale;
24731 commands_list.x=commands_window.x+8;
24732
24733 commands_x.w = 20;
24734 commands_x.h = bh;
24735 commands_x.x = commands_list.x + commands_list.tw() - commands_x.w;
24736 commands_x.y = by;
24737
24738 commands_infobtn.w = 20;
24739 commands_infobtn.h = bh;
24740 commands_infobtn.x = commands_x.x - commands_infobtn.w;
24741 commands_infobtn.y = by;
24742
24743 commands_zoombtn.w = 20;
24744 commands_zoombtn.h = bh;
24745 commands_zoombtn.x = commands_infobtn.x - commands_zoombtn.w;
24746 commands_zoombtn.y = by;
24747
24748 commands_txt.x = commands_list.x;
24749 commands_txt.y = by+(bh-text_height(get_zc_font(font_lfont_l)))/2;
24750
24751 favorites_x.x = favorites_window.x + favorites_window.w - favorites_x.w - 2;
24752 favorites_x.y = favorites_list.y-15;
24753
24754 favorites_infobtn.x = favorites_x.x - favorites_infobtn.w;
24755 favorites_infobtn.y = favorites_x.y;
24756
24757 favorites_zoombtn.x = favorites_infobtn.x - favorites_zoombtn.w;
24758 favorites_zoombtn.y = favorites_infobtn.y;
24759
24760 favorites_pgright.x = favorites_zoombtn.x - favorites_pgright.w;
24761 favorites_pgright.y = favorites_zoombtn.y;
24762
24763 favorites_pgleft.x = favorites_pgright.x - favorites_pgleft.w;
24764 favorites_pgleft.y = favorites_pgleft.y;
24765
24766 txtoffs_single.x = 22;
24767 txtoffs_single.y = 6;
24768 txtoffs_double_1.x = 22;
24769 txtoffs_double_1.y = 2;
24770 txtoffs_double_2.x = 22;
24771 txtoffs_double_2.y = 10;
24772 panel_align = 0;
24773
24774 int sqx = minimap.x+minimap.tw();
24775 squares_panel.set(sqx,main_panel.y,main_panel.tw()-sqx,main_panel.th());
24776 int x2 = sqx+4;
24777 int x1 = x2 - (20+(8*3)+2);
24778 int y1 = main_panel.y+10;
24779 int sw = 20, sh = 20;
24780 int offs = sh+4;
24781
24782 itemsqr_pos.set(x2,y1+(0*offs),sw,sh);
24783 flagsqr_pos.set(x2,y1+(1*offs),sw,sh);
24784 stairsqr_pos.set(x2,y1+(2*offs),sw,sh);
24785 warparrival_pos.set(x2,y1+(6*offs),sw,sh);
24786
24787 enemy_prev_pos.x = main_panel.x+14;
24788 enemy_prev_pos.y = main_panel.y+12 + minimap.h;
24789 enemy_prev_pos.w = 4;
24790 enemy_prev_pos.h = 3;
24791 enemy_prev_pos.xscale = 16;
24792 enemy_prev_pos.yscale = 16;
24793 enemy_prev_pos.fw = enemy_prev_pos.xscale*2;
24794 enemy_prev_pos.fh = enemy_prev_pos.yscale*2;
24795
24796 warpret_pos[0].set(x1,y1+(4*offs),sw,sh);
24797 warpret_pos[1].set(x1,y1+(5*offs),sw,sh);
24798 warpret_pos[2].set(x2,y1+(4*offs),sw,sh);
24799 warpret_pos[3].set(x2,y1+(5*offs),sw,sh);
24800
24801 auto& last_alias_list = comboaliaslist[num_combo_cols-1];
24802 combopool_preview.x=comboaliaslist[0].x;
24803 combopool_preview.y=last_alias_list.y+(last_alias_list.h*last_alias_list.yscale)+16;
24804 combopool_preview.w=(last_alias_list.x+(last_alias_list.w*last_alias_list.xscale))-comboaliaslist[0].x;
24805 combopool_preview.h=(favorites_window.y-combopool_preview.y);//+favorites_window.h-10;
24806 combopool_preview.w -= combopool_preview.w%16;
24807 combopool_preview.h -= combopool_preview.h%16;
24808
24809 FONT* tfont = get_zc_font(font_lfont_l);
24810 combopool_prevbtn.w = text_length(tfont, "Unweighted")+10;
24811 combopool_prevbtn.h = 11;
24812 combopool_prevbtn.x = combopool_preview.x;
24813 combopool_prevbtn.y = combopool_preview.y-combopool_prevbtn.h;
24814
24815 mappage_count = 9;
24816
24817 txfont = get_zc_font(font_lfont_l);
24818 combo_preview_text1.set(combo_preview.x-9,combo_preview.y,1,3,1,text_height(txfont));
24819 combo_preview_text2.set(combo_preview2.x+combo_preview2.w+8,combo_preview2.y,1,3,1,text_height(txfont));
24820
24821 favorites_x.w = 30;
24822 favorites_infobtn.w = 30;
24823 favorites_zoombtn.w = 30;
24824 favorites_pgleft.w = 30;
24825 favorites_pgright.w = 30;
24826 }
24827 //Same in all modes
24828 {
24829
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(is_compact ? compact_zoomed_cmd : large_zoomed_cmd)
24830 {
24831 8 commands_list.w /= 2;
24832 8 commands_list.xscale *= 2;
24833 8 }
24834
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(is_compact ? compact_zoomed_fav : large_zoomed_fav)
24835 {
24836
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(favorites_list.w%2)
24837 favorites_list.x += (favorites_list.xscale / 2);
24838 8 favorites_list.xscale *= 2;
24839 8 favorites_list.yscale *= 2;
24840 8 favorites_list.w /= 2;
24841 8 favorites_list.h /= 2;
24842 8 }
24843
24844 8 favorites_x.h = 14;
24845 8 favorites_x.x = favorites_window.x + favorites_window.w - favorites_x.w - 2;
24846 8 favorites_x.y = favorites_list.y-15;
24847
24848 8 favorites_infobtn.h = favorites_x.h;
24849 8 favorites_infobtn.x = favorites_x.x - favorites_infobtn.w;
24850 8 favorites_infobtn.y = favorites_x.y;
24851
24852 8 favorites_zoombtn.h = favorites_infobtn.h;
24853 8 favorites_zoombtn.x = favorites_infobtn.x - favorites_zoombtn.w;
24854 8 favorites_zoombtn.y = favorites_infobtn.y;
24855
24856 8 favorites_pgright.h = favorites_zoombtn.h;
24857 8 favorites_pgright.x = favorites_zoombtn.x - favorites_pgright.w;
24858 8 favorites_pgright.y = favorites_zoombtn.y;
24859
24860 8 favorites_pgleft.h = favorites_pgright.h;
24861 8 favorites_pgleft.x = favorites_pgright.x - favorites_pgleft.w;
24862 8 favorites_pgleft.y = favorites_pgright.y;
24863
24864 8 mainbar.x = dialogs[0].x+dialogs[0].w;
24865 8 mainbar.y = 0;
24866 8 mainbar.w = zoomoutbtn.x-mainbar.x;
24867 8 mainbar.h = drawmode_btn.h;
24868 }
24869
24870 //Ensure current combo list selected is valid
24871 8 current_combolist=vbound(current_combolist,0,num_combo_cols-1);
24872 8 current_comboalist=vbound(current_comboalist,0,num_combo_cols-1);
24873 8 current_cpoollist=vbound(current_cpoollist,0,num_combo_cols-1);
24874 8 current_cautolist = vbound(current_cautolist, 0, num_combo_cols - 1);
24875
24876 //Generate bitmaps
24877 8 init_bitmap(&mapscreenbmp,16*(showedges?18:16),16*(showedges?13:11));
24878 8 init_bitmap(&brushbmp,256*mapscreen_screenunit_scale,176*mapscreen_screenunit_scale);
24879 8 init_bitmap(&brushscreen,(256+(showedges?16:0))*mapscreen_screenunit_scale,(176+(showedges?16:0))*mapscreen_screenunit_scale);
24880
24881 8 init_bitmap(&screen2,zq_screen_w,zq_screen_h);
24882 8 init_bitmap(&tmp_scr,zq_screen_w,zq_screen_h);
24883 8 init_bitmap(&menu1,zq_screen_w,zq_screen_h);
24884 8 init_bitmap(&menu3,zq_screen_w,zq_screen_h);
24885
24886 8 center_zq_class_dialogs();
24887 8 center_zq_files_dialogs();
24888 8 center_zq_subscreen_dialogs();
24889 8 center_zq_tiles_dialogs();
24890 8 center_zquest_dialogs();
24891
24892 8 aspect_ratio = zq_screen_h / double(zq_screen_w);
24893
24894 8 mmap_init();
24895 8 }
24896
24897 11 void remove_locked_params_on_exit()
24898 {
24899 11 al_trace("Removing timers. \n");
24900 11 remove_int(fps_callback);
24901 11 remove_int(dclick_check);
24902 11 }
24903
24904 11 void destroy_bitmaps_on_exit()
24905 {
24906 11 al_trace("Cleaning bitmaps...");
24907 11 destroy_bitmap(screen2);
24908 11 destroy_bitmap(tmp_scr);
24909 11 destroy_bitmap(menu1);
24910 11 destroy_bitmap(menu3);
24911 11 destroy_bitmap(mapscreenbmp);
24912 11 destroy_bitmap(dmapbmp_small);
24913 11 destroy_bitmap(dmapbmp_large);
24914 11 destroy_bitmap(brushbmp);
24915 11 destroy_bitmap(brushscreen);
24916 11 al_trace("...");
24917
24918
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 11 times.
539 for(int32_t i=0; i<MOUSE_BMP_MAX*4; i++)
24919 {
24920 528 destroy_bitmap(mouse_bmp[i/4][i%4]);
24921 528 destroy_bitmap(mouse_bmp_1x[i/4][i%4]);
24922 528 }
24923
24924
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 11 times.
363 for(int32_t i=0; i<ICON_BMP_MAX*4; i++)
24925 352 destroy_bitmap(icon_bmp[i/4][i%4]);
24926
24927
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 11 times.
715 for(int32_t i=0; i<16*4; i++)
24928 704 destroy_bitmap(flag_bmp[i/4][i%4]);
24929
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 11 times.
33 for(int32_t i=0; i<2; i++)
24930 22 destroy_bitmap(select_bmp[i]);
24931
24932
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 11 times.
99 for(int32_t i=0; i<MAXARROWS; i++)
24933 88 destroy_bitmap(arrow_bmp[i]);
24934
24935 11 al_trace(" OK. \n");
24936 11 }
24937
24938
24939 11 void quit_game()
24940 {
24941 11 set_last_timed_save(nullptr);
24942 11 save_config_file();
24943 11 zc_set_palette(black_palette);
24944 11 zc_stop_midi();
24945
24946 11 remove_locked_params_on_exit();
24947
24948 11 al_trace("Cleaning sfx. \n");
24949
24950
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<WAV_COUNT; i++)
24951 {
24952
2/2
✓ Branch 0 taken 2805 times.
✓ Branch 1 taken 11 times.
2816 if(customsfxdata[i].data!=NULL)
24953 {
24954 // delete [] customsfxdata[i].data;
24955 2805 free(customsfxdata[i].data);
24956 2805 }
24957
24958
1/2
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
2816 delete [] sfx_string[i];
24959 2816 }
24960
24961
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<MAXWPNS; i++)
24962 {
24963
1/2
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
2816 delete [] weapon_string[i];
24964 2816 }
24965
24966
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<MAXITEMS; i++)
24967 {
24968
1/2
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
2816 delete [] item_string[i];
24969 2816 }
24970
24971
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 11 times.
5643 for(int32_t i=0; i<eMAXGUYS; i++)
24972 {
24973
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 delete [] guy_string[i];
24974 5632 }
24975
24976 11 al_trace("Cleaning script buffer. \n");
24977
24978
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 11 times.
5643 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
24979 {
24980
2/4
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5632 times.
5632 if(ffscripts[i]!=NULL) delete ffscripts[i];
24981 5632 }
24982
24983
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
24984 {
24985
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(itemscripts[i]!=NULL) delete itemscripts[i];
24986 2816 }
24987
24988
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
24989 {
24990
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(guyscripts[i]!=NULL) delete guyscripts[i];
24991 2816 }
24992
24993
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
24994 {
24995
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
24996 2816 }
24997
24998
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
24999 {
25000
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
25001 2816 }
25002
25003
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
25004 {
25005
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(screenscripts[i]!=NULL) delete screenscripts[i];
25006 2816 }
25007
25008
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 11 times.
44 for(int32_t i=0; i<3; i++) //should this be NUMSCRIPTGLOBAL or NUMSCRIPTGLOBALOLD? -Z
25009 {
25010
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(globalscripts[i]!=NULL) delete globalscripts[i];
25011 33 }
25012
25013
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 11 times.
66 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
25014 {
25015
2/4
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 55 times.
55 if(playerscripts[i]!=NULL) delete playerscripts[i];
25016 55 }
25017
25018
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
25019 {
25020
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
25021 2816 }
25022
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
25023 {
25024
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
25025 2816 }
25026
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 11 times.
5643 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
25027 {
25028
2/4
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5632 times.
5632 if(comboscripts[i]!=NULL) delete comboscripts[i];
25029 5632 }
25030
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2816 times.
2827 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
25031 {
25032
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(subscreenscripts[i]!=NULL) delete subscreenscripts[i];
25033 2816 }
25034
25035 11 al_trace("Cleaning qst buffers. \n");
25036 11 del_qst_buffers();
25037
25038
25039 11 al_trace("Cleaning midis. \n");
25040
25041
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(customtunes)
25042 {
25043
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<MAXCUSTOMMIDIS_ZQ; i++)
25044 2816 customtunes[i].reset();
25045
25046 11 free(customtunes);
25047 11 }
25048
25049 11 al_trace("Cleaning undotilebuf. \n");
25050
25051 11 undocombobuf.clear();
25052
25053
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3 times.
11 if(newundotilebuf)
25054 {
25055
2/2
✓ Branch 0 taken 1716000 times.
✓ Branch 1 taken 8 times.
1716008 for(int32_t i=0; i<NEWMAXTILES; i++)
25056
1/2
✓ Branch 0 taken 1716000 times.
✗ Branch 1 not taken.
1716000 if(newundotilebuf[i].data) free(newundotilebuf[i].data);
25057
25058 8 free(newundotilebuf);
25059 8 }
25060
25061
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(filepath) free(filepath);
25062
25063
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(datapath) free(datapath);
25064
25065
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(midipath) free(midipath);
25066
25067
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(imagepath) free(imagepath);
25068
25069
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(tmusicpath) free(tmusicpath);
25070
25071
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(last_timed_save) free(last_timed_save);
25072
25073 11 destroy_bitmaps_on_exit();
25074 11 }
25075
25076 void quit_game2()
25077 {
25078 set_last_timed_save(nullptr);
25079 save_config_file();
25080 zc_set_palette(black_palette);
25081 zc_stop_midi();
25082
25083 remove_locked_params_on_exit();
25084
25085 al_trace("Cleaning sfx. \n");
25086
25087 for(int32_t i=0; i<WAV_COUNT; i++)
25088 {
25089 if(customsfxdata[i].data!=NULL)
25090 {
25091 // delete [] customsfxdata[i].data;
25092 free(customsfxdata[i].data);
25093 }
25094
25095 delete [] sfx_string[i];
25096 }
25097
25098 for(int32_t i=0; i<MAXWPNS; i++)
25099 {
25100 delete [] weapon_string[i];
25101 }
25102
25103 for(int32_t i=0; i<MAXITEMS; i++)
25104 {
25105 delete [] item_string[i];
25106 }
25107
25108 for(int32_t i=0; i<eMAXGUYS; i++)
25109 {
25110 delete [] guy_string[i];
25111 }
25112
25113 al_trace("Cleaning script buffer. \n");
25114
25115 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
25116 {
25117 if(ffscripts[i]!=NULL) delete ffscripts[i];
25118 }
25119
25120 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
25121 {
25122 if(itemscripts[i]!=NULL) delete itemscripts[i];
25123 }
25124
25125 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
25126 {
25127 if(guyscripts[i]!=NULL) delete guyscripts[i];
25128 }
25129
25130 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
25131 {
25132 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
25133 }
25134
25135 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
25136 {
25137 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
25138 }
25139
25140 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
25141 {
25142 if(screenscripts[i]!=NULL) delete screenscripts[i];
25143 }
25144
25145 for(int32_t i=0; i<3; i++) //should this be NUMSCRIPTGLOBAL or NUMSCRIPTGLOBALOLD? -Z
25146 {
25147 if(globalscripts[i]!=NULL) delete globalscripts[i];
25148 }
25149
25150 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
25151 {
25152 if(playerscripts[i]!=NULL) delete playerscripts[i];
25153 }
25154
25155 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
25156 {
25157 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
25158 }
25159 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
25160 {
25161 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
25162 }
25163 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
25164 {
25165 if(comboscripts[i]!=NULL) delete comboscripts[i];
25166 }
25167 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
25168 {
25169 if(subscreenscripts[i]!=NULL) delete subscreenscripts[i];
25170 }
25171
25172 al_trace("Cleaning qst buffers. \n");
25173 del_qst_buffers();
25174
25175
25176 al_trace("Cleaning midis. \n");
25177
25178 if(customtunes)
25179 {
25180 for(int32_t i=0; i<MAXCUSTOMMIDIS_ZQ; i++)
25181 customtunes[i].reset();
25182
25183 free(customtunes);
25184 }
25185
25186 al_trace("Cleaning undotilebuf. \n");
25187
25188 undocombobuf.clear();
25189
25190 if(newundotilebuf)
25191 {
25192 for(int32_t i=0; i<NEWMAXTILES; i++)
25193 if(newundotilebuf[i].data) free(newundotilebuf[i].data);
25194
25195 free(newundotilebuf);
25196 }
25197
25198 if(filepath) free(filepath);
25199
25200 if(datapath) free(datapath);
25201
25202 if(midipath) free(midipath);
25203
25204 if(imagepath) free(imagepath);
25205
25206 if(tmusicpath) free(tmusicpath);
25207
25208 if(last_timed_save) free(last_timed_save);
25209 }
25210
25211 8 void center_zquest_dialogs()
25212 {
25213 8 jwin_center_dialog(assignscript_dlg);
25214 8 jwin_center_dialog(autolayer_dlg);
25215 8 center_zq_cset_dialogs();
25216 8 jwin_center_dialog(change_track_dlg);
25217 8 jwin_center_dialog(csetfix_dlg);
25218 8 jwin_center_dialog(dmapmaps_dlg);
25219 8 center_zq_door_dialogs();
25220 8 jwin_center_dialog(editcomboa_dlg);
25221 8 jwin_center_dialog(editinfo_dlg);
25222 8 jwin_center_dialog(editmusic_dlg);
25223 8 jwin_center_dialog(editshop_dlg);
25224 8 jwin_center_dialog(ffcombo_sel_dlg);
25225 8 jwin_center_dialog(getnum_dlg);
25226 8 jwin_center_dialog(layerdata_dlg);
25227 8 jwin_center_dialog(list_dlg);
25228 8 jwin_center_dialog(loadmap_dlg);
25229 8 jwin_center_dialog(misccolors_dlg);
25230 8 jwin_center_dialog(newcomboa_dlg);
25231 8 jwin_center_dialog(orgcomboa_dlg);
25232 8 jwin_center_dialog(path_dlg);
25233 8 jwin_center_dialog(screen_pal_dlg);
25234 8 jwin_center_dialog(secret_dlg);
25235 8 jwin_center_dialog(selectmusic_dlg);
25236 8 jwin_center_dialog(showpal_dlg);
25237 8 jwin_center_dialog(strlist_dlg);
25238 8 jwin_center_dialog(template_dlg);
25239 8 jwin_center_dialog(tp_dlg);
25240 8 jwin_center_dialog(under_dlg);
25241 8 jwin_center_dialog(tilewarp_dlg);
25242 8 jwin_center_dialog(sidewarp_dlg);
25243 8 jwin_center_dialog(warpring_dlg);
25244 8 center_zscript_dialogs();
25245 8 }
25246
25247
25248 void animate_coords()
25249 {
25250 coord_frame=(coord_timer>>3)&3;
25251
25252 if(++coord_timer>=(1<<5))
25253 {
25254 coord_timer=0;
25255 }
25256 }
25257
25258 static const char *help_list[] =
25259 {
25260 "PREVIEW MODE",
25261 "PgUp/PgDn - Scroll through hotkey list",
25262 "Esc/Enter - Exit Preview Mode",
25263 "R - Restore screen to original state",
25264 "C - Toggle combo cycling On/Off",
25265 "S - Trigger screen secrets",
25266 "Q/W/F - These still work",
25267 "P - Pause everything",
25268 "A - Advance frame-by-frame",
25269 "1-4 - Trigger tile warp A-D",
25270 "5-8 - Trigger side warp A-D",
25271 "9 - Enable timed warps",
25272 "",
25273 "",
25274 };
25275
25276 void do_previewtext()
25277 {
25278 FONT* oldfont = font;
25279 font = get_zc_font(font_lfont_l);
25280
25281 //Put in help areas
25282 auto& sqr = preview_text;
25283 int ind = 0, len = 0;
25284 for(int q = 0; q < 12; ++q)
25285 {
25286 int l = text_length(font, help_list[q]);
25287 if(len < l) len = l;
25288 }
25289 sqr.xscale = len+2;
25290 sqr.yscale = text_height(font);
25291 for(int col = 0; col < sqr.w; ++col)
25292 {
25293 for(int row = 0; row < sqr.h; ++row)
25294 {
25295 auto& line = sqr.subsquare(col,row);
25296 textprintf_ex(menu1,font,line.x,line.y,jwin_pal[jcTEXTFG],-1,"%s",help_list[ind++]);
25297 }
25298 }
25299
25300 font = oldfont;
25301 }
25302
25303
25304 bool reload_fonts = false;
25305 void run_zq_frame()
25306 {
25307 if(reload_fonts)
25308 {
25309 init_custom_fonts();
25310 load_size_poses();
25311 reload_fonts = false;
25312 }
25313
25314 domouse();
25315 custom_vsync();
25316 refresh(rCLEAR|rALL);
25317 }
25318 8 int32_t d_nbmenu_proc(int32_t msg,DIALOG *d,int32_t c)
25319 {
25320
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
8 switch(msg)
25321 {
25322 case MSG_VSYNC:
25323 run_zq_frame();
25324 break;
25325 case MSG_GOTMOUSE:
25326 case MSG_XCHAR:
25327 ComboBrushPause=1;
25328 refresh(rMAP);
25329 ComboBrushPause=0;
25330 clear_tooltip();
25331 break;
25332 }
25333
25334 8 return GuiMenu::proc(msg,d,c);
25335 }
25336
25337 bool prv_press=false;
25338
25339 void dopreview()
25340 {
25341 refresh(rMAP);
25342
25343 while(!(gui_mouse_b()))
25344 {
25345 if(keypressed())
25346 {
25347 if(!prv_press)
25348 {
25349 prv_press=true;
25350
25351 switch(readkey()>>8)
25352 {
25353 case KEY_ESC:
25354 case KEY_ENTER:
25355 case KEY_ENTER_PAD:
25356 goto finished;
25357 break;
25358
25359 case KEY_F:
25360 Flags^=cFLAGS;
25361 refresh(rMAP);
25362 break;
25363
25364 case KEY_R:
25365 onReloadPreview();
25366 break;
25367
25368 case KEY_S:
25369 onSecretsPreview();
25370 break;
25371
25372 case KEY_C:
25373 onCopy();
25374 break;
25375
25376 case KEY_A:
25377 onAKey();
25378 break;
25379
25380 case KEY_P:
25381 onP();
25382 break;
25383
25384 case KEY_L:
25385 onShowDarkness();
25386 break;
25387
25388 case KEY_1:
25389 Map.prv_dowarp(0,0);
25390 prv_warp=0;
25391 break;
25392
25393 case KEY_2:
25394 Map.prv_dowarp(0,1);
25395 prv_warp=0;
25396 break;
25397
25398 case KEY_3:
25399 Map.prv_dowarp(0,2);
25400 prv_warp=0;
25401 break;
25402
25403 case KEY_4:
25404 Map.prv_dowarp(0,3);
25405 prv_warp=0;
25406 break;
25407
25408 case KEY_5:
25409 Map.prv_dowarp(1,0);
25410 prv_warp=0;
25411 break;
25412
25413 case KEY_6:
25414 Map.prv_dowarp(1,1);
25415 prv_warp=0;
25416 break;
25417
25418 case KEY_7:
25419 Map.prv_dowarp(1,2);
25420 prv_warp=0;
25421 break;
25422
25423 case KEY_8:
25424 Map.prv_dowarp(1,3);
25425 prv_warp=0;
25426 break;
25427
25428 case KEY_9:
25429 if(prv_twon)
25430 {
25431 prv_twon=0;
25432 Map.set_prvtime(0);
25433 prv_warp=0;
25434 }
25435 else
25436 {
25437 Map.set_prvtime(Map.get_prvscr()->timedwarptics);
25438 prv_twon=1;
25439 }
25440
25441 break;
25442
25443 case KEY_W:
25444 onShowWalkability();
25445 break;
25446
25447 case KEY_Q:
25448 onShowComboInfoCSet();
25449 break;
25450 }
25451 }
25452 else
25453 {
25454 readkey();
25455 }
25456 }
25457 else
25458 {
25459 prv_press=false;
25460 }
25461
25462 if(prv_warp)
25463 {
25464 Map.prv_dowarp(1,0);
25465 prv_warp=0;
25466 }
25467
25468 if(Map.get_prvfreeze())
25469 {
25470 if(Map.get_prvadvance())
25471 {
25472 custom_vsync();
25473 Map.set_prvadvance(0);
25474 }
25475 }
25476 else
25477 {
25478 custom_vsync();
25479 Map.set_prvadvance(0);
25480 }
25481
25482 refresh(rALL);
25483 }
25484
25485 finished:
25486 //Flags=of;
25487 reset_combo_animations();
25488 reset_combo_animations2();
25489 MouseSprite::set(ZQM_NORMAL);
25490 prv_mode=0;
25491 prv_warp=0;
25492 Map.end_prv();
25493 loadlvlpal(Map.getcolor());
25494 rebuild_trans_table();
25495 refresh(rMAP+rMENU);
25496
25497 while(gui_mouse_b())
25498 {
25499 /* do nothing */
25500 rest(1);
25501 }
25502 }
25503
25504 void call_vidmode_dlg();
25505 int32_t onZQVidMode()
25506 {
25507 call_vidmode_dlg();
25508 return D_O_K;
25509 }
25510
25511 bool screenIsScrolling()
25512 {
25513 return false;
25514 }
25515
25516 void write_includepaths()
25517 {
25518 FILE* f = fopen("includepaths.txt", "w");
25519 if(f)
25520 {
25521 fwrite(FFCore.includePathString,1,strlen(FFCore.includePathString),f);
25522 fclose(f);
25523 }
25524 }
25525
25526 11 int32_t save_config_file()
25527 {
25528
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (!application_has_loaded) return 0;
25529
25530 char qtnametitle[20];
25531 char qtpathtitle[20];
25532 char *datapath2=(char *)malloc(2048);
25533 char *midipath2=(char *)malloc(2048);
25534 char *imagepath2=(char *)malloc(2048);
25535 char *tmusicpath2=(char *)malloc(2048);
25536 strcpy(datapath2, datapath);
25537 strcpy(midipath2, midipath);
25538 strcpy(imagepath2, imagepath);
25539 strcpy(tmusicpath2, tmusicpath);
25540 chop_path(datapath2);
25541 chop_path(midipath2);
25542 chop_path(imagepath2);
25543 chop_path(tmusicpath2);
25544 write_includepaths();
25545
25546 zc_set_config("zquest",data_path_name,datapath2);
25547 zc_set_config("zquest",midi_path_name,midipath2);
25548 zc_set_config("zquest",image_path_name,imagepath2);
25549 zc_set_config("zquest",tmusic_path_name,tmusicpath2);
25550
25551 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
25552 {
25553 window_width = al_get_display_width(all_get_display());
25554 window_height = al_get_display_height(all_get_display());
25555 zc_set_config("zquest","window_width",window_width);
25556 zc_set_config("zquest","window_height",window_height);
25557 }
25558 if (all_get_display() && !all_get_fullscreen_flag() && SaveWinPos)
25559 {
25560 int o_window_x, o_window_y;
25561 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
25562 zc_set_config("zquest", "window_x", o_window_x);
25563 zc_set_config("zquest", "window_y", o_window_y);
25564 }
25565
25566 byte b = 0;
25567 for(int32_t x=0; x<7; x++)
25568 {
25569 set_bit(&b,x,LayerMaskInt[x]);
25570 }
25571
25572 zc_set_config("zquest","layer_mask",b);
25573
25574 flush_config_file();
25575 #ifdef __EMSCRIPTEN__
25576 em_sync_fs();
25577 #endif
25578 free(datapath2);
25579 free(midipath2);
25580 free(imagepath2);
25581 free(tmusicpath2);
25582 return 0;
25583 11 }
25584
25585 int32_t d_timer_proc(int32_t msg, DIALOG *d, int32_t c)
25586 {
25587 //these are here to bypass compiler warnings about unused arguments
25588 c=c;
25589 d=d;
25590
25591 switch(msg)
25592 {
25593 case MSG_IDLE:
25594 #ifdef _WIN32
25595 if(zqUseWin32Proc != FALSE)
25596 win32data.Update(Frameskip); //experimental win32 fixes
25597
25598 #endif
25599
25600 // This has been crashing on Windows, and it saves plenty without it
25601 //check_autosave();
25602 break;
25603 }
25604
25605 return D_O_K;
25606 }
25607
25608 void check_autosave()
25609 {
25610 if (!first_save)
25611 return;
25612
25613 if(AutoSaveInterval>0)
25614 {
25615 time(&auto_save_time_current);
25616 auto_save_time_diff = difftime(auto_save_time_current,auto_save_time_start);
25617
25618 if(auto_save_time_diff>AutoSaveInterval*60)
25619 {
25620 MouseSprite::set(ZQM_NORMAL);
25621 replace_extension(last_timed_save, filepath, "qt0", 2047);
25622 set_last_timed_save(last_timed_save);
25623 go();
25624
25625 if((header.zelda_version != ZELDA_VERSION || header.build != VERSION_BUILD))
25626 {
25627 jwin_alert("Auto Save","This quest was saved in an older version of ZQuest.","If you wish to use the autosave feature, you must manually","save the files in this version first.","OK",NULL,13,27,get_zc_font(font_lfont));
25628 time(&auto_save_time_start);
25629 comeback();
25630 return;
25631 }
25632
25633 int32_t ret = save_quest(last_timed_save, true);
25634
25635 if(ret)
25636 {
25637 jwin_alert("Error","Timed save did not complete successfully.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
25638 set_last_timed_save(nullptr);
25639 }
25640
25641 save_config_file();
25642 time(&auto_save_time_start);
25643 comeback();
25644 }
25645 }
25646 }
25647
25648 void flushItemCache(bool) {}
25649 void ringcolor(bool forceDefault)
25650 {
25651 forceDefault=forceDefault;
25652 }
25653
25654 bool item_disabled(int32_t)
25655 {
25656 return false;
25657 }
25658
25659 int32_t onCmdExit()
25660 {
25661 // replaces onExit for the -large button command "Exit"
25662 close_button_quit = true;
25663 return 0;
25664 }
25665
25666 int32_t onQuickCompile()
25667 {
25668 if(do_compile_and_slots(1,false))
25669 {
25670 saved = false;
25671 InfoDialog("Quick Compile","Success!").show();
25672 }
25673 else
25674 {
25675 InfoDialog("Quick Compile","Failure!").show();
25676 }
25677 return 0;
25678 }
25679 int32_t onSmartCompile()
25680 {
25681 if(do_compile_and_slots(2,false))
25682 {
25683 saved = false;
25684 InfoDialog("Smart Compile","Success!").show();
25685 }
25686 else
25687 {
25688 InfoDialog("Smart Compile","Failure!").show();
25689 }
25690 return 0;
25691 }
25692
25693 int32_t strchrnum(char const* str, char c)
25694 {
25695 for(int32_t i=0; str[i]; ++i)
25696 {
25697 if(str[i]==c)
25698 {
25699 return i;
25700 }
25701 }
25702
25703 return -1;
25704 }
25705
25706 int32_t get_longest_line_length(FONT *f, char* str)
25707 {
25708 int32_t maxlen=0;
25709 char* tmpstr = str;
25710 char temp=0;
25711 int32_t t=0;
25712 int32_t new_t=-1;
25713 while(tmpstr[0])
25714 {
25715 t=strchrnum(tmpstr, '\n');
25716
25717 if(t==-1)
25718 {
25719 t=(int32_t)strlen(tmpstr);
25720 }
25721
25722 if((uint32_t)t!=strlen(tmpstr))
25723 {
25724 new_t=t+1;
25725 }
25726 else
25727 {
25728 new_t=-1;
25729 }
25730
25731 temp = tmpstr[t];
25732 tmpstr[t]=0;
25733 maxlen=zc_max(maxlen,text_length(f, tmpstr));
25734 tmpstr[t]=temp;
25735
25736 if(new_t!=-1)
25737 {
25738 tmpstr+=new_t;
25739 }
25740 else break;
25741 }
25742 return maxlen;
25743 }
25744
25745 int32_t count_lines(char const* str)
25746 {
25747 int32_t count=1;
25748
25749 for(word i=0; i<strlen(str); ++i)
25750 {
25751 if(str[i]=='\n')
25752 {
25753 ++count;
25754 }
25755 }
25756
25757 return count;
25758 }
25759
25760 void debug_pos(size_and_pos const& pos, int color)
25761 {
25762 if(pos.w < 1 || pos.h < 1)
25763 return;
25764 if(pos.xscale > 1 || pos.yscale > 1)
25765 {
25766 auto maxind = pos.w*pos.h;
25767 for(auto q = 0; q < maxind; ++q)
25768 {
25769 auto& sub = pos.subsquare(q);
25770 if(sub.x < 0) break;
25771 highlight_sqr(screen, color, sub, 1);
25772 }
25773 }
25774 else
25775 {
25776 if(pos.fw > -1 && pos.fh > -1)
25777 highlight_frag(screen, color, pos, 1);
25778 else highlight_sqr(screen, color, pos, 1);
25779 }
25780 }
25781
25782 void textbox_out(BITMAP* dest, FONT* font, int x, int y, int fg, int bg, char const* str, int align, size_and_pos* dims)
25783 {
25784 static size_and_pos nilsz;
25785 size_and_pos& txbox = dims ? *dims : nilsz;
25786
25787 char* kill = (char*)malloc(strlen(str)+1);
25788 char *tmpstr = kill;
25789 strcpy(tmpstr,str);
25790
25791 while(tmpstr[0] == '\n')
25792 ++tmpstr;
25793 int len = strlen(tmpstr);
25794 while(tmpstr[len-1] == '\n')
25795 tmpstr[--len] = 0;
25796
25797 txbox.x=x;
25798 txbox.y=y;
25799 int32_t lines=count_lines(tmpstr);
25800 txbox.w = 1;
25801 txbox.h = lines;
25802 txbox.xscale = get_longest_line_length(font, tmpstr);
25803 txbox.yscale = text_height(font);
25804
25805 int ax = 0; //Aligned x
25806 switch(align)
25807 {
25808 case 0: //left
25809 break;
25810 case 1: //center
25811 txbox.x -= txbox.xscale/2;
25812 ax = txbox.xscale/2;
25813 break;
25814 case 2: //right
25815 txbox.x -= txbox.xscale;
25816 ax = txbox.xscale;
25817 break;
25818 }
25819
25820 int bw = txbox.w*txbox.xscale;
25821 int bh = txbox.h*txbox.yscale;
25822 BITMAP* outbmp = create_bitmap_ex(8, bw, bh);
25823 clear_to_color(outbmp, bg);
25824
25825 char temp = 0;
25826 int32_t t=0;
25827 int32_t new_t=-1;
25828 int32_t line=0;
25829
25830 while(tmpstr[t])
25831 {
25832 t=strchrnum(tmpstr, '\n');
25833
25834 if(t==-1)
25835 t=(int32_t)strlen(tmpstr);
25836
25837 if((uint32_t)t!=strlen(tmpstr))
25838 new_t=t+1;
25839 else
25840 new_t=-1;
25841
25842 temp = tmpstr[t];
25843 tmpstr[t]=0;
25844 gui_textout_ln(outbmp, font, (ucc*)tmpstr, ax, (line*txbox.yscale), fg, -1, align);
25845 tmpstr[t]=temp;
25846 ++line;
25847
25848 if(new_t!=-1)
25849 {
25850 tmpstr+=new_t;
25851 t=0;
25852 }
25853 }
25854
25855 blit(outbmp, dest, 0, 0, txbox.x, txbox.y, bw, bh);
25856 destroy_bitmap(outbmp);
25857 free(kill);
25858 }
25859
25860 void highlight_sqr(BITMAP* dest, int color, int x, int y, int w, int h, int thick)
25861 {
25862 for(int q = 0; q < thick; ++q)
25863 {
25864 safe_rect(dest, x+q, y+q, x+w-1-q, y+h-1-q, color);
25865 }
25866 }
25867 void highlight_sqr(BITMAP* dest, int color, size_and_pos const& rec, int thick)
25868 {
25869 highlight_sqr(dest, color, rec.x, rec.y, rec.tw(), rec.th(), thick);
25870 }
25871 void highlight_frag(BITMAP* dest, int color, int x1, int y1, int w, int h, int fw, int fh, int thick)
25872 {
25873 int xc = x1+fw-1;
25874 int yc = y1+fh-1;
25875 int x2 = x1+w-1;
25876 int y2 = y1+h-1;
25877
25878 hline(dest, x1, y1, x2, color);
25879 vline(dest, x1, y1, y2, color);
25880
25881 hline(dest, x1, y2, xc, color);
25882 vline(dest, x2, y1, yc, color);
25883 hline(dest, xc, yc, x2, color);
25884 vline(dest, xc, yc, y2, color);
25885 }
25886 void highlight_frag(BITMAP* dest, int color, size_and_pos const& rec, int thick)
25887 {
25888 highlight_frag(dest, color, rec.x, rec.y, rec.tw(), rec.th(), rec.fw, rec.fh, thick);
25889 }
25890
25891 void highlight(BITMAP* dest, size_and_pos& hl)
25892 {
25893 if(hl.fw > -1 && hl.fh > -1)
25894 {
25895 highlight_frag(dest, hl.data[1], hl, hl.data[0]);
25896 }
25897 else highlight_sqr(dest, hl.data[1], hl, hl.data[0]);
25898 }
25899
25900 std::pair<int, int> get_box_text_size(char const* tipmsg, double txscale)
25901 {
25902 if(txscale < 1) txscale = 1;
25903 char* kill = (char*)malloc(strlen(tipmsg)+1);
25904 char *tmpstr = kill;
25905 strcpy(tmpstr,tipmsg);
25906
25907 while(tmpstr[0] == '\n')
25908 ++tmpstr;
25909 int len = strlen(tmpstr);
25910 while(tmpstr[len-1] == '\n')
25911 tmpstr[--len] = 0;
25912
25913 int32_t lines = count_lines(tmpstr);
25914 int txlen = get_longest_line_length(font, tmpstr);
25915 int txhei = lines*text_height(font);
25916 int tx_sclen = (txlen * txscale);
25917 int tx_schei = (txhei * txscale);
25918 int w = tx_sclen + 8 + 1;
25919 int h = tx_schei + 8 + 1;
25920 if (w > zq_screen_w)
25921 w = zq_screen_w;
25922 if (h > zq_screen_h)
25923 h = zq_screen_h;
25924 return {w, h};
25925 }
25926
25927 void draw_box(BITMAP* destbmp, size_and_pos* pos, char const* tipmsg, double txscale)
25928 {
25929 if(txscale < 1) txscale = 1;
25930 char* kill = (char*)malloc(strlen(tipmsg)+1);
25931 char *tmpstr = kill;
25932 strcpy(tmpstr,tipmsg);
25933
25934 while(tmpstr[0] == '\n')
25935 ++tmpstr;
25936 int len = strlen(tmpstr);
25937 while(tmpstr[len-1] == '\n')
25938 tmpstr[--len] = 0;
25939
25940 auto& box = *pos;
25941 clear_bitmap(destbmp);
25942
25943 int32_t lines=count_lines(tmpstr);
25944 int txlen = get_longest_line_length(font, tmpstr);
25945 int txhei = lines*text_height(font);
25946 int tx_sclen = (txlen * txscale);
25947 int tx_schei = (txhei * txscale);
25948 box.w = tx_sclen + 8 + 1;
25949 box.h = tx_schei + 8 + 1;
25950 if (box.w > zq_screen_w)
25951 box.w = zq_screen_w;
25952 if (box.h > zq_screen_h)
25953 box.h = zq_screen_h;
25954
25955 if(box.x+box.w>=zq_screen_w)
25956 {
25957 box.x=(zq_screen_w - box.w);
25958 }
25959
25960 if(box.y+box.h>=zq_screen_h)
25961 {
25962 box.y=(zq_screen_h - box.h);
25963 }
25964
25965 rectfill(destbmp, 1, 1, box.w-3, box.h-3, jwin_pal[jcTEXTBG]);
25966 rect(destbmp, 0, 0, box.w-2, box.h-2, jwin_pal[jcTEXTFG]);
25967 vline(destbmp, box.w-1, 0, box.h-1, jwin_pal[jcTEXTFG]);
25968 hline(destbmp, 1, box.h-1, box.w-2, jwin_pal[jcTEXTFG]);
25969 destbmp->line[box.h-1][0]=0;
25970 destbmp->line[0][box.w-1]=0;
25971
25972 char temp = 0;
25973 int32_t t=0;
25974 int32_t new_t=-1;
25975 int32_t line=0;
25976
25977 BITMAP* txbmp = create_bitmap_ex(8,box.w,box.h);
25978 clear_bitmap(txbmp);
25979 while(tmpstr[t])
25980 {
25981 t=strchrnum(tmpstr, '\n');
25982
25983 if(t==-1)
25984 {
25985 t=(int32_t)strlen(tmpstr);
25986 }
25987
25988 if((uint32_t)t!=strlen(tmpstr))
25989 {
25990 new_t=t+1;
25991 }
25992 else
25993 {
25994 new_t=-1;
25995 }
25996
25997 temp = tmpstr[t];
25998 tmpstr[t]=0;
25999 textprintf_ex(txbmp, font, 0, (line*text_height(font)), jwin_pal[jcTEXTFG], -1, "%s", tmpstr);
26000 tmpstr[t]=temp;
26001 ++line;
26002
26003 if(new_t!=-1)
26004 {
26005 tmpstr+=new_t;
26006 t=0;
26007 }
26008 }
26009 masked_stretch_blit(txbmp,destbmp,0,0,txlen,txhei,4,4,tx_sclen,tx_schei);
26010 destroy_bitmap(txbmp);
26011 free(kill);
26012 }
26013
26014 void update_tooltip(int32_t x, int32_t y, size_and_pos const& sqr, char const* tipmsg, double scale)
26015 {
26016 update_tooltip(x,y,sqr.x,sqr.y,sqr.w*sqr.xscale,sqr.h*sqr.yscale,tipmsg,sqr.fw,sqr.fh,scale);
26017 }
26018 void update_tooltip(int32_t x, int32_t y, int32_t tx, int32_t ty, int32_t tw, int32_t th, char const* tipmsg, int fw, int fh, double scale)
26019 {
26020 if(!EnableTooltips)
26021 {
26022 return;
26023 }
26024
26025 ttip_install(ttip_global_id, tipmsg, tx, ty, tw, th, x, y, fw, fh);
26026 }
26027
26028 void ZQ_ClearQuestPath()
26029 {
26030 zc_set_config("zquest","win_last_quest",(char const*)nullptr);
26031 strcpy(filepath,"");
26032 }
26033
26034 //FFCore
26035
26036 void FFScript::init()
26037 {
26038 for ( int32_t q = 0; q < wexLast; q++ ) warpex[q] = 0;
26039 numscriptdraws = 0;
26040 max_ff_rules = qr_MAX;
26041 temp_no_stepforward = 0;
26042 nostepforward = 0;
26043
26044 coreflags = 0;
26045 skip_ending_credits = 0;
26046 music_update_cond = 0;
26047 music_update_flags = 0;
26048 for ( int32_t q = 0; q < susptLAST; q++ ) { system_suspend[q] = false; }
26049
26050 //for ( int32_t q = 0; q < 512; q++ ) FF_rules[q] = 0;
26051 int32_t usr_midi_volume = usr_digi_volume = usr_sfx_volume = usr_music_volume = usr_panstyle = 0;
26052 FF_hero_action = 0;
26053 enemy_removal_point[spriteremovalY1] = -32767;
26054 enemy_removal_point[spriteremovalY2] = 32767;
26055 enemy_removal_point[spriteremovalX1] = -32767;
26056 enemy_removal_point[spriteremovalX2] = 32767;
26057 enemy_removal_point[spriteremovalZ1] = -32767;
26058 enemy_removal_point[spriteremovalZ2] = 32767;
26059
26060 for ( int32_t q = 0; q < 4; q++ )
26061 {
26062 FF_screenbounds[q] = 0;
26063 FF_screen_dimensions[q] = 0;
26064 FF_subscreen_dimensions[q] = 0;
26065 FF_eweapon_removal_bounds[q] = 0;
26066 FF_lweapon_removal_bounds[q] = 0;
26067 }
26068 for ( int32_t q = 0; q < FFSCRIPTCLASS_CLOCKS; q++ )
26069 {
26070 FF_clocks[q] = 0;
26071 }
26072 for ( int32_t q = 0; q < SCRIPT_DRAWING_RULES; q++ )
26073 {
26074 ScriptDrawingRules[q] = 0;
26075 }
26076 for ( int32_t q = 0; q < NUM_USER_MIDI_OVERRIDES; q++ )
26077 {
26078 FF_UserMidis[q] = 0;
26079 }
26080 subscreen_scroll_speed = 0; //make a define for a default and read quest override! -Z
26081 kb_typing_mode = false;
26082 initIncludePaths();
26083 }
26084
26085 void FFScript::updateIncludePaths()
26086 {
26087 includePaths.clear();
26088 int32_t pos = 0; int32_t pathnumber = 0;
26089 for ( int32_t q = 0; includePathString[pos]; ++q )
26090 {
26091 int32_t dest = 0;
26092 char buf[2048] = {0};
26093 while(includePathString[pos] != ';' && includePathString[pos])
26094 {
26095 buf[dest] = includePathString[pos];
26096 ++pos;
26097 ++dest;
26098 }
26099 ++pos;
26100 string str(buf);
26101 includePaths.push_back(str);
26102 }
26103 }
26104
26105 void FFScript::initIncludePaths()
26106 {
26107 memset(includePathString,0,sizeof(includePathString));
26108 FILE* f = fopen("includepaths.txt", "r");
26109 if(f)
26110 {
26111 int32_t pos = 0;
26112 int32_t c;
26113 do
26114 {
26115 c = fgetc(f);
26116 if(c!=EOF)
26117 includePathString[pos++] = c;
26118 }
26119 while(c!=EOF && pos<MAX_INCLUDE_PATH_CHARS);
26120 if(pos<MAX_INCLUDE_PATH_CHARS)
26121 includePathString[pos] = '\0';
26122 includePathString[MAX_INCLUDE_PATH_CHARS-1] = '\0';
26123 fclose(f);
26124 }
26125 else strcpy(includePathString, "include/;headers/;scripts/;");
26126 al_trace("Full path string is: ");
26127 safe_al_trace(includePathString);
26128 al_trace("\n");
26129 updateIncludePaths();
26130
26131 for ( size_t q = 0; q < includePaths.size(); ++q )
26132 {
26133 al_trace("Include path %zu: ",q);
26134 safe_al_trace(includePaths.at(q).c_str());
26135 al_trace("\n");
26136 }
26137 }
26138
26139 int32_t FFScript::getQRBit(int32_t rule)
26140 {
26141 return ( get_qr(rule) ? 1 : 0 );
26142 }
26143
26144 int32_t FFScript::getTime(int32_t type)
26145 {
26146 //struct tm *tm_struct = localtime(time(NULL));
26147 struct tm * tm_struct;
26148 time_t rawtime;
26149 time (&rawtime);
26150 tm_struct = localtime (&rawtime);
26151
26152 switch(type)
26153 {
26154 case curyear:
26155 {
26156 int32_t year = tm_struct->tm_year + 1900; /* year */
26157 //year format starts at 1900, so we add it to the return
26158 return year;
26159
26160 }
26161 case curmonth:
26162 {
26163 int32_t month = tm_struct->tm_mon +1; /* month */
26164 //Months start at 0, but we want 1->12
26165 return month;
26166 }
26167 case curday_month:
26168 {
26169 int32_t day_month = tm_struct->tm_mday; /* day of the month */
26170 return day_month;
26171 }
26172 case curday_week:
26173 {
26174 int32_t day_week = tm_struct->tm_wday; /* day of the week */
26175 return day_week;
26176 }
26177 case curhour:
26178 {
26179 int32_t hour = tm_struct->tm_hour; /* hours */
26180 return hour;
26181 }
26182 case curminute:
26183 {
26184 int32_t minutes = tm_struct->tm_min; /* minutes */
26185 return minutes;
26186 }
26187 case cursecond:
26188 {
26189 int32_t secs = tm_struct->tm_sec; /* seconds */
26190 return secs;
26191 }
26192 case curdayyear:
26193 {
26194 int32_t day_year = tm_struct->tm_yday; /* day in the year */
26195 return day_year;
26196 }
26197 case curDST:
26198 {
26199 int32_t isDST = tm_struct->tm_isdst; /* daylight saving time */
26200 return isDST;
26201 }
26202 default: return -1;
26203
26204 }
26205 }
26206
26207 extern const char *itemclass_help_string_defaults[itype_max];
26208
26209 /* end */
26210
26211 24576 int32_t FFScript::getQuestHeaderInfo(int32_t type)
26212 {
26213 24576 return quest_format[type];
26214 }
26215
26216 bool isSideViewGravity(int32_t t)
26217 {
26218 return (Map.CurrScr()->flags7&fSIDEVIEW) != 0;
26219 }
26220
26221
26222
26223
26224 void FFScript::ZScriptConsole(bool open)
26225 {
26226
26227
26228 #ifdef _WIN32
26229 if ( console_is_open )
26230 {
26231 zscript_coloured_console.Create("ZQuest Classic Logging Console", 600, 200);
26232 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
26233 zscript_coloured_console.gotoxy(0,0);
26234 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
26235 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZQuest Classic Logging Console\n");
26236 }
26237 else
26238 {
26239 //close
26240 zscript_coloured_console.Close();
26241 }
26242 #endif
26243 }
26244
26245 template <typename ...Params>
26246 void FFScript::ZScriptConsole(int32_t attributes,const char *format, Params&&... params)
26247 {
26248 #ifdef _WIN32
26249 initConsole();
26250 zscript_coloured_console.cprintf( attributes, format, std::forward<Params>(params)... );
26251 #endif
26252 }
26253
26254 int32_t getpitfall(int32_t x, int32_t y){return 0;}
26255
26256 bool update_hw_pal = false;
26257 void update_hw_screen()
26258 {
26259 if (is_headless())
26260 return;
26261
26262 framecnt++;
26263
26264 zc_process_display_events();
26265 if (update_hw_pal)
26266 {
26267 zc_set_palette(RAMpal);
26268 update_hw_pal = false;
26269 }
26270
26271 render_timer_wait();
26272 render_zq();
26273 }
26274
26275 bool checkCost(int32_t ctr, int32_t amnt)
26276 {
26277 if(!game) return true;
26278 if(amnt <= 0) return true;
26279 switch (ctr)
26280 {
26281 case crMONEY: //rupees
26282 {
26283 if ( current_item_power(itype_wallet) ) return true;
26284 break;
26285 }
26286 case crMAGIC: //magic
26287 {
26288 if (get_qr(qr_ENABLEMAGIC))
26289 {
26290 return (((current_item_power(itype_magicring) > 0)
26291 ? game->get_maxmagic()
26292 : game->get_magic()+game->get_dmagic())>=amnt*game->get_magicdrainrate());
26293 }
26294 return true;
26295 }
26296 case crARROWS:
26297 {
26298 if(current_item_power(itype_quiver))
26299 return true;
26300 if(!get_qr(qr_TRUEARROWS))
26301 return checkCost(crMONEY, amnt);
26302 break;
26303 }
26304 case crBOMBS:
26305 {
26306 if(current_item_power(itype_bombbag))
26307 return true;
26308 break;
26309 }
26310 case crSBOMBS:
26311 {
26312 if(current_item_power(itype_bombbag)
26313 && itemsbuf[current_item_id(itype_bombbag)].flags & item_flag1)
26314 return true;
26315 break;
26316 }
26317 }
26318 return (game->get_counter(ctr)+game->get_dcounter(ctr)>=amnt);
26319 }
26320 bool checkmagiccost(int32_t itemid, bool checkTime)
26321 {
26322 if(itemid < 0)
26323 {
26324 return false;
26325 }
26326 itemdata const& id = itemsbuf[itemid];
26327 return checkCost(id.cost_counter[0], id.cost_amount[0])
26328 && checkCost(id.cost_counter[1], id.cost_amount[1]);
26329 }
26330
26331 void payCost(int32_t ctr, int32_t amnt, int32_t tmr, bool ignoreTimer)
26332 {
26333 return;
26334 }
26335 void paymagiccost(int32_t itemid, bool ignoreTimer, bool onlyTimer)
26336 {
26337 return;
26338 }
26339 bool is_in_scrolling_region()
26340 {
26341 return false;
26342 }
26343
26344 void enter_sys_pal(){}
26345 void exit_sys_pal(){}
26346
26347 void replay_step_comment(std::string comment) {}
26348 bool replay_is_active() {return false;}
26349 9 bool replay_is_replaying() {return false;}
26350 bool replay_version_check(int min, int max) {return false;}
26351 bool replay_is_debug() {return false;}
26352 std::string replay_get_meta_str(std::string key){return "";}
26353 int32_t item::run_script(int32_t mode){return 0;};
26354 ffcdata* slopes_getFFC(int id)
26355 {
26356 return nullptr;
26357 }
26358
26359 #ifdef __EMSCRIPTEN__
26360 extern "C" void open_test_mode()
26361 {
26362 int dmap = -1;
26363 int32_t pal = Map.getcolor();
26364 for(auto q = 0; q < MAXDMAPS; ++q)
26365 {
26366 if(DMaps[q].map == Map.getCurrMap())
26367 {
26368 if(pal == DMaps[q].color)
26369 {
26370 dmap = q;
26371 break;
26372 }
26373 if(dmap < 0)
26374 dmap = q;
26375 }
26376 }
26377 if(dmap < 0) dmap = 0;
26378
26379 em_open_test_mode(filepath, dmap, Map.getCurrScr(), -1);
26380 }
26381
26382 extern "C" void get_shareable_url()
26383 {
26384 EM_ASM({
26385 ZC.setShareableUrl({open: UTF8ToString($0), map: $1, screen: $2});
26386 }, filepath, Map.getCurrMap(), Map.getCurrScr());
26387 }
26388 #endif
26389
26390 11 void setZScriptVersion(int32_t v){}
26391